I'm trying to apply different colors to the text of individual tick mark values. Below is an example of code I tried; also tried
valueattrs = (color = red color= green color = blue);
which didn't work either.
Any suggestions?
data a;
District = 'D1'; score = 6; output;
District = 'D2'; score = 6; output;
District = 'D3'; score = 6; output;
run;
proc sgplot data=a;
hbar District/response=score;
yAXIS
values=('D1' 'D2' 'D3')
valueattrs = (color = red green blue);
run;
You could use YAXISTABLE statement to simulate the tick value of Y axis .
Check this post:
data dattrmap;
infile cards truncover;
input id $ value $ textcolor $;
datalines;
code D1 red
code D2 green
code D3 blue
;
data a;
District = 'D1'; score = 6; output;
District = 'D2'; score = 6; output;
District = 'D3'; score = 6; output;
run;
proc sgplot data=a dattrmap=dattrmap ;
hbarparm category=District response=score;
xaxis display=(nolabel) ;
yaxis display=(nolabel novalues) ;
yaxistable District/nolabel y=District valueattrs=(size=10pt) position=left textgroup=District textgroupid=code;
run;
Hi did you wanted to achieve something like this
proc template;
define statgraph MyGraphTemplate;
begingraph;
layout overlay /
xaxisopts=(label="X Axis Label" labelattrs=(color=blue size=12pt))
yaxisopts=(label="Y Axis Label" labelattrs=(color=red size=12pt));
scatterplot x=weight y=height;
endlayout;
endgraph;
end;
run;
proc sgrender data=sashelp.class template=MyGraphTemplate;
run;
For more on this please see the below link
Creating and Customizing Graphics using Graph Template Language
Not the LABEL, but thank you for the suggestion. I'm trying to apply different colors to the axis tick mark values - in the example, the text D1, D2, and D3
You could use YAXISTABLE statement to simulate the tick value of Y axis .
Check this post:
data dattrmap;
infile cards truncover;
input id $ value $ textcolor $;
datalines;
code D1 red
code D2 green
code D3 blue
;
data a;
District = 'D1'; score = 6; output;
District = 'D2'; score = 6; output;
District = 'D3'; score = 6; output;
run;
proc sgplot data=a dattrmap=dattrmap ;
hbarparm category=District response=score;
xaxis display=(nolabel) ;
yaxis display=(nolabel novalues) ;
yaxistable District/nolabel y=District valueattrs=(size=10pt) position=left textgroup=District textgroupid=code;
run;
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!
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.
Ready to level-up your skills? Choose your own adventure.