Hello All,
Is there is any way to assign different colors to each axis (X and Y) separately ?
With below code, color getting assigned for both the axis line. But I need to assign different colors to each axis.
proc template;
define style styles.axis;
parent=styles.htmlblue;
class GraphAxisLines /
contrastcolor=red;
end;
run;
ods html style=axis;
proc sgplot data=sashelp.class;
scatter x=weight y=height;
run;
But my requirement is as below :
Any suggestions greatly appreciated !!
Regards,
Sanjeev.K
%sganno
data sganno;
%SGARROW( X1=0, Y1=0,X2=0,Y2=100,DIRECTION= "OUT",X1SPACE="WALLPERCENT",Y2SPACE="WALLPERCENT",
X2SPACE="WALLPERCENT",Y1SPACE="WALLPERCENT",LINECOLOR="blue" ,SHAPE="BARBED" )
%SGARROW( X1=0, Y1=0,X2=100,Y2=0,DIRECTION= "OUT",X1SPACE="WALLPERCENT",Y2SPACE="WALLPERCENT",
X2SPACE="WALLPERCENT",Y1SPACE="WALLPERCENT",LINECOLOR="green" ,SHAPE="BARBED" )
run;
proc sgplot data=sashelp.class noborder sganno=sganno noautolegend ;
scatter x=weight y=height/datalabel=name group=sex;
yaxis label='Y' labelpos=top ;
xaxis label='X' labelpos=right;
run;
Thanks @Ksharp ,
Is there any we can do this with proc template ?
Im using SGRENDER in my program. Apologies for not being clear with in my earlier post.
Don't know how much of this still holds but check out this 2019 post from @Jay54 re: some GTL limitations as well as some suggested workarounds. I wonder if in your case you could suppress the real axis lines and instead use REFERENCELINEs at x=0 and y=0, which would allow you to specify different COLORs for LINEATTRs. Good luck!
According to TC , add two refline to mock X Y axis.
proc sgplot data=sashelp.class noborder;
scatter x=weight y=height;
refline 50.5/axis=x lineattrs=(thickness=4 color=green);
refline 50/axis=y lineattrs=(thickness=4 color=red);
yaxis offsetmin=0 display=(noline);
xaxis offsetmin=0 display=(noline);
run;
The commonest color blindness cannot distinguish red from green. Sanjeev.K actually wanted black and green. (Look for more of my work on communication effective use of color and on Visual Data Insights.)
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.