Hello,
I have a bar graph developed almost how I need it (using PROC SGPLOT), but the colors are getting reset upon adding a SCATTER statement to my code. I'm trying add some reference points to each series.
The data points appear to be getting plotted correctly, which makes me think it's possible to combine the two types, but the colors resetting makes me think it is not possible.
I have some code like the following:
data sample;
set sashelp.baseball;
where team = "Chicago" and Div = "NE";
ref1 = 15;
ref2 = 20;
ref3 = 25;
ref4 = nHome + 5;
run;
proc sgplot data=sample;
styleattrs
dataColors=(gray darkgray lightgray black)
dataContrastColors=(gray darkgray lightgray black);
hbarparm category = Position response=ref3 / barwidth=0.7;
hbarparm category = Position response=ref2 / barwidth=0.7;
hbarparm category = Position response=ref1 / barwidth=0.7;
hbarparm category = Position response=nHome / barwidth=0.4;
/*scatter y=Position x=ref4;*/
run;
Uncommenting the SCATTER statement plots the data points as intended, but makes all series light blue. Is it possible to control the colors in this scenario? Ideally I'd retain the colors of the bars and make the scatter plot dots orange.
I appreciate any help in advance!
Thank you,
Brian
Add the CYCLEATTRS option to the PROC SGPLOT statement. What is happening is that CYCLEATTRS is automatically enabled when all of your plot statements are the same type. When you added the SCATTER statement, we could not automatically determine if CYCLEATTRS is what you wanted. You can always force it using the option.
Hope this helps!
Dan
Have you tried data attribute maps?
I tried specifying the colours using fillattrs option on each HBARPARM and that didn't seem to work unfortunately.
Add the CYCLEATTRS option to the PROC SGPLOT statement. What is happening is that CYCLEATTRS is automatically enabled when all of your plot statements are the same type. When you added the SCATTER statement, we could not automatically determine if CYCLEATTRS is what you wanted. You can always force it using the option.
Hope this helps!
Dan
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 16. 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.