Graphics Programming

Data visualization using SAS programming, including ODS Graphics and SAS/GRAPH. Charts, plots, maps, and more!
BookmarkSubscribeRSS Feed
sullivan0822
Calcite | Level 5

I have a vertical bar chart, using SGPLOT, with two categories 4 groups in each.  When the category names are short, the x axis has nice min and max offsets and looks great.  But when the names are longer the offsets disappear.  Tried offsetmin , max on the xaxis statement and this fixes one side while making the other worse.  Tried discreteoffset this doesn't work either.  I previously have used GCHART for this particular plot, and I was able to manipulate the axis exactly how I wanted but I would prefer to use SGPLOT.  I would like to get the second plot to look more like the first one.

SHORTNAME.pngLONGNAME.png

2 REPLIES 2
Jay54
Meteorite | Level 14

I think it is a bug related to the inside legend.  If you put the legend outside, it seems to compute the offsets correctly.  With inside legend, you could work around by setting the cluster width to 0.7.

Or set yaxis offsetmax=0.1 which seems to trigger a relayout of the graph fixing the problem.

Offsets are computed by the graph to accommodate the tick values.  If you set offsetmin and offsetmax, they override the values computed, so make sure your offset settings are large enough (offsetmin=0.2).

Outside legend:

SGPlotLongValues.png

Inside Legend:

SGPlotLongValues.png

data longcatvalues;
  label grp='Quartile';
  do cat='A_Long_Label', 'B_Long_Label';
    do grp='QTR1', 'QTR2', 'QTR3', 'QTR4';
   response=20*(1+0.2*ranuni(2));
   output;
end;
  end;
run;


proc sgplot data=longcatvalues;
  vbar cat / response=response group=grp groupdisplay=cluster;
  keylegend / location=inside across=4 position=topleft;
  yaxis offsetmax=0.1;
  run;

sullivan0822
Calcite | Level 5

Yes both these fix it thank you (yaxis offset or clusterwidth).  I would not have thought of the y-axis offset.  Thank you!

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

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