Hi all,
I have create a SGPLOT scatter graph and group the display data by indicator 'gender'. I wonder how can I change the dot color within the group (for example: male for green dot, female for purple dot) to make the graph easier to read? The code I created is in below:
PROC SGPLOT DATA=ClassPopulation NOAUTOLEGEND; scatter X=height Y=weight / GROUP=gender ; XAx
is MAX= 250;Yaxis MIN= 50 MAX= 300;
RUN;
Thanks a Lot!
You can override the current style assignments with the STYLEATTRS statement.
styleattrs datacontrastcolors=(green purple);
will set the first value of the group variable to green and the second to purple, so with your data you may need to switch the order the colors appear. You can override fill colors, line colors and patterns as well. Datacontrastcolor is used for markers or boundaries of bars.
If you want to be consistent for the color assignment in multiple graphs you would either make sure the sort order so that the "first" group value is the same.
OR investigate the DATTRMAP data set to allow consistent settings for group values regardless of data order.
You can override the current style assignments with the STYLEATTRS statement.
styleattrs datacontrastcolors=(green purple);
will set the first value of the group variable to green and the second to purple, so with your data you may need to switch the order the colors appear. You can override fill colors, line colors and patterns as well. Datacontrastcolor is used for markers or boundaries of bars.
If you want to be consistent for the color assignment in multiple graphs you would either make sure the sort order so that the "first" group value is the same.
OR investigate the DATTRMAP data set to allow consistent settings for group values regardless of data order.
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!
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.