BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Dave25
Quartz | Level 8

 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;
1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

You could use YAXISTABLE statement to simulate the tick value of Y axis .

Check this post:

https://communities.sas.com/t5/Graphics-Programming/Customize-fonts-using-attribute-map/m-p/972511#M...

 

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;

Ksharp_0-1757056841320.png

 

View solution in original post

4 REPLIES 4
himself
Pyrite | Level 9

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;

image.png 

 

For more on this please see the below link 

Creating and Customizing Graphics using Graph Template Language 

Dave25
Quartz | Level 8

 

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

 

SGPlot412.png

Ksharp
Super User

You could use YAXISTABLE statement to simulate the tick value of Y axis .

Check this post:

https://communities.sas.com/t5/Graphics-Programming/Customize-fonts-using-attribute-map/m-p/972511#M...

 

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;

Ksharp_0-1757056841320.png

 

Dave25
Quartz | Level 8
didn't think of the "position=left" - thanks!

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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
  • 4 replies
  • 639 views
  • 2 likes
  • 3 in conversation