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

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
	;
	XAxis MAX= 250;
  Yaxis MIN= 50 MAX= 300;
RUN;

 Thanks a Lot!

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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. 

View solution in original post

1 REPLY 1
ballardw
Super User

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. 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 2133 views
  • 2 likes
  • 2 in conversation