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!

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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