Data visualization with SAS programming

customizing axis labels in sgplot

Reply
Contributor
Posts: 57

customizing axis labels in sgplot

I need to plot a horizontal bar chart and will like to make certain labels bold, also with borders and background colors.

I have being struggling with this issue for a while please I need urgent help .

I have included a sample of my program for any one who wish to help

 

ods listing style=listing;
ods graphics/ width= 10in height=10.81in ;
goptions  gunit=pct rotate=landscape ftext= "Arial";
goptions htext=13pt htitle=15pt gsfname=cgrt1;
ods graphics on / reset=index imagename="test1";

data anno;
 length label $25;
set test.exports; retain function 'text' xsys 'datavalue' width 80 textweight 'bold' border 'true' linecolor 'lightblue' fillcolor 'lightblue' ; yc1=melde_grup ; label=melde_grup; if grup in ("Cars") then x1=-10; if grup in ("Electronics") then x1=8; if grup in ("Utensils") then x1=11; run;
title "my exports"; proc sgplot data=test.exports sganno=anno pad=(bottom=5%); styleattrs datacolors=(gray green); yaxis grid type=discrete discreteorder=data; hbar type /response=reported group=area groupdisplay=cluster barwidth=0.8 missing ; yaxis display=(nolabel) offsetmin=0.05 offsetmax=0.05; xaxis label='exports in %' grid offsetmin=0.0 offsetmax=0.05; keylegend / location=outside position=bottomleft across=1 title="" exclude=(" "); run;
orderTypereportedareagrup
1Cars   
2Pegueot100your_companyCars
3Fiat84,1your_companyCars
4Nissan92,6your_companyCars
5Electronics your_company 
6TV15,2your_companyElectronics
7Radio15,2your_companyElectronics
8Iron15,2your_companyElectronics
9Tablett15,2your_companyElectronics
10Utensils your_company 
11Frying pan70your_companyUtensils
12Cutleries your_companyUtensils
13Plates12,8your_companyUtensils
14Knives your_companyUtensils
15Pots50,4your_companyUtensils
1Cars   
2Pegueot88,3regionCars
3Fiat88,3regionCars
4Nissan regionCars
5Electronics99,6region 
6TV84,7regionElectronics
7Radio73,4regionElectronics
8Iron70,2regionElectronics
9Tablett70,6regionElectronics
10Utensils84,8region 
11Frying pan regionUtensils
12Cutleries69,1regionUtensils
13Plates68,1regionUtensils
14Knives68,1regionUtensils
15Pots51,7regionUtensils

 

I want the cars , electronics and Utensils to be bold with borders and background color as in data anno. This is not working fine. I will appreciate any help

SAS Super FREQ
Posts: 1,265

Re: customizing axis labels in sgplot

[ Edited ]

This seems similar in nature to the Forest Plot example in this blog article.  You can do some of this using the AxisTable with SAS 9.4 or later.  Backgrounds may require some other solution.

Contributor
Posts: 57

Re: customizing axis labels in sgplot

Posted in reply to Sanjay_SAS

Thanks I will try that to see if it works

SAS Super FREQ
Posts: 1,265

Re: customizing axis labels in sgplot

Contributor
Posts: 57

Re: customizing axis labels in sgplot

Posted in reply to Sanjay_SAS

Thanks a lot Sanjay for your support. When I use the yaxistable in sgplot, it displays the whole group as table on the yaxis.

That is not what I really want. When  I use sganno it works but if I apply the same syntax for another procedure with different variable it doesn't . I don't really understand that because every is the same only the variable change.

 

Anyway if am able to solve that I will leave a post.

Thanks

Ask a Question
Discussion stats
  • 4 replies
  • 297 views
  • 0 likes
  • 2 in conversation