BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
svh
Lapis Lazuli | Level 10 svh
Lapis Lazuli | Level 10

I am trying to make a panel plot in which each panel has a set of gray lines that represent individual units and a dark blue line that is the average of those units.The problem with my chart is that I cannot seem to place the blue line atop the other gray lines. As you can see, the blue line is behind the gray ones.

 

svh_0-1647632236010.png

 

I am currently using an attribute map to style the blue line. The gray lines get their color from within the SGPANEL procedure as such:

 

data attrmap;
     length ID $ 10 Value $ 8 linecolor $ 15 markercolor $ 15 linethickness 3 linepattern $ 10 markersymbol $ 20;
    infile datalines delimiter='|';
    input id  value  linecolor  markercolor linethickness linepattern markersymbol ;
	cards;
	SchoolID|Mean|CX004c6d |CX004c6d|4|Solid|SquareFilled
	;


proc sgpanel data= have  noautolegend dattrmap=attrmap;
  panelby class_new1 / spacing=5 novarname rows=3 columns=2 sort=data ;
  styleattrs datacolors=(gray) datacontrastcolors=(gray) datasymbols=(circle) datalinepatterns=(shortdash) ;
  series x=DOU_var y=DOU_score / group=SchoolID attrid=SchoolID name="line";
  scatter x=dou_var y=dou_score/ group=SchoolID attrid=SchoolID jitter  transparency=.2;
 rowaxis grid min=0 max=1;

Are there ways to put the blue line atop the other gray ones so that it stands out?

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

If I understand what you are saying, that is because your "blue line" is drawn before the others. If the blue line come from a different value of the Group variable then it likely means that the value for that line is seen by the proc before the others and drawn first.

 

If this were my project I would have separate plot statement that just created the blue line, possibly a different group variable that is only defined for the blue line, that is after the first series plot. Make the Blue not transparent for greatest contrast. Something like

proc sgpanel data= have  noautolegend dattrmap=attrmap;
  panelby class_new1 / spacing=5 novarname rows=3 columns=2 sort=data ;
  styleattrs datacolors=(gray) datacontrastcolors=(gray) datasymbols=(circle) datalinepatterns=(shortdash) ;
  series x=DOU_var y=DOU_score / group=SchoolID attrid=SchoolID name="line";

series x=DOU_var y=DOU_score / group=OtherSchoolID attrid=otherSchoolID ;

  scatter x=dou_var y=dou_score/ group=SchoolID attrid=SchoolID jitter  transparency=.2;
 rowaxis grid min=0 max=1;

Which would require either adding another attrid to the Dattrmap OR you could specify the color directly with a lineattrs statement. If the OtherSchoolID variable is only on some records those are tho only wants shown.

Need to add a Keylegend to only show the "Line" items to prevent two "blue" line entries in the legend with this approach.

 

Another may be to sort the data so the "blue Line" group appears last in the data order but can't tell how difficult that may be without example data.

View solution in original post

1 REPLY 1
ballardw
Super User

If I understand what you are saying, that is because your "blue line" is drawn before the others. If the blue line come from a different value of the Group variable then it likely means that the value for that line is seen by the proc before the others and drawn first.

 

If this were my project I would have separate plot statement that just created the blue line, possibly a different group variable that is only defined for the blue line, that is after the first series plot. Make the Blue not transparent for greatest contrast. Something like

proc sgpanel data= have  noautolegend dattrmap=attrmap;
  panelby class_new1 / spacing=5 novarname rows=3 columns=2 sort=data ;
  styleattrs datacolors=(gray) datacontrastcolors=(gray) datasymbols=(circle) datalinepatterns=(shortdash) ;
  series x=DOU_var y=DOU_score / group=SchoolID attrid=SchoolID name="line";

series x=DOU_var y=DOU_score / group=OtherSchoolID attrid=otherSchoolID ;

  scatter x=dou_var y=dou_score/ group=SchoolID attrid=SchoolID jitter  transparency=.2;
 rowaxis grid min=0 max=1;

Which would require either adding another attrid to the Dattrmap OR you could specify the color directly with a lineattrs statement. If the OtherSchoolID variable is only on some records those are tho only wants shown.

Need to add a Keylegend to only show the "Line" items to prevent two "blue" line entries in the legend with this approach.

 

Another may be to sort the data so the "blue Line" group appears last in the data order but can't tell how difficult that may be without example data.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 1 reply
  • 419 views
  • 0 likes
  • 2 in conversation