BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
AnnaHawgood
Fluorite | Level 6

Hi

 

I've made the following scatterplot with sgplot and would like to add background colors, so that:

  • the top right corner (defined by x>0.75, y>0) is green
  • the bottom left corner (define by x<=0.75, y<=0) is red
  • the top left and bottom right corners (x<=0.75, y>0 and x>0-75, y<0) are yellow

 

Is there a way of doing this in proc sgplot (I have attached my data as a xlsx-file)?

 

Graph:

 

  Udklip.PNG

 

Code:

title "Lovoverholdelsesprocenter over tid - §50-Undersøgelser";
 proc sgplot data=graf dattrmap=attrmap_bu noborder ;
  where sagstrin ? "2" and 'Med i Baselin'n ne '';
  scatter x=pct_118 y=diff / group=spg attrid=spg;
  styleattrs datacolors=(red yellow green);
  xaxis min=-0 max=1 values=(0 to 1 by 0.1) fitpolicy=rotate valuesrotate=diagonal valueattrs=(Family=Helvetica Size=8) label="Lovoverholdelse 1. kvt./18";
  yaxis min=-0.4 max=0.5 values=(-0.4 to 0.5 by 0.1) valueattrs=(Family=Helvetica Size=8) label="Frem-/tilbagegang ift. 4/17 i procentpoint";
  refline 0 /axis=y;
  refline 0.75 /axis=x;
  *keylegend "underniv" / across=3 noborder valueattrs=(Family=Helvetica Size=7);
run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
Jay54
Meteorite | Level 14

If you know the data extents, use POLYGON plot to display the 4 regions you want.

View solution in original post

2 REPLIES 2
Jay54
Meteorite | Level 14

If you know the data extents, use POLYGON plot to display the 4 regions you want.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 907 views
  • 0 likes
  • 2 in conversation