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. 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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
  • 1454 views
  • 2 likes
  • 2 in conversation