BookmarkSubscribeRSS Feed
☑ This topic is solved. 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 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 1 reply
  • 184 views
  • 0 likes
  • 2 in conversation