LOESS Curve in PROC SGPLOT--problem with legend

Reply
New Contributor
Posts: 2

LOESS Curve in PROC SGPLOT--problem with legend

I am trying to show two LOESS curves on a single plot for data composed of resonders and non-responders. Because the data points are close together, I need to change the color of the LOESS curves so they are visible. When I do this (using lineattrs) it changes the color of both groups so I go from blue and red data points and lines to two black lines. The legend is for the lines, and doesn't include the data points, so now there are no labels for which group the blue stars and red circles are in.

Does anyone know how to fix this? Can I force the legend to include the scatter points as well as the smoothing curves? Is there another approach outside of SGPLOT that would be a better solution for this type of graph?

Below is the code I am using.

Thanks!

proc sgplot data=dat;

     loess y=apap_cys x=alt /smooth=0.8 group=responder lineattrs=(color=black);

run;

Respected Advisor
Posts: 4,641

Re: LOESS Curve in PROC SGPLOT--problem with legend

By using lineattrs= option, you force both curves to have the same color. You can either use a SG attribute map dataset (SAS 9.3 and above) to get full control, or simply use:

proc sgplot data=dat;

     loess y=apap_cys x=alt /smooth=0.8 group=responder lineattrs=(pattern=Solid);

run;

to let the color but not the line pattern be controled by the default style.

PG

PG
New Contributor
Posts: 2

Re: LOESS Curve in PROC SGPLOT--problem with legend

Can you go into more detail about the SG attribute map dataset?

Respected Advisor
Posts: 4,641

Re: LOESS Curve in PROC SGPLOT--problem with legend

Read the whole story starting here:

SAS(R) 9.3 ODS Graphics: Procedures Guide, Third Edition

and the following pages.

PG

PG
Ask a Question
Discussion stats
  • 3 replies
  • 350 views
  • 0 likes
  • 2 in conversation