How to change plot size in proc sgplot? NOT graph size (which includes the plot itself, title, axis titles, etc.), but only the area bound by axes.
One option (if you really do want to control the actual length of the axes ... not just the offset/origin so 2 graphs line up) is to use SAS/Graph gplot, which lets you directly specify the length of the axes. Here is an example:
goptions xpixels=400 ypixels=400 border cback=pink;
axis1 length=2.2in origin=(35pct,25pct);
axis2 length=2.2in;
proc gplot data=sashelp.class;
plot height*weight / haxis=axis1 vaxis=axis2;
run;
proc gplot data=sashelp.class;
plot name*weight / haxis=axis1 vaxis=axis2;
run;
It's just a set of basic plots:
********
ods graphics on / width=500PX height=400PX;
proc sgplot data=mydata;
by variable1;
scatter x=variable2 y=variable3 / colorresponse=variable4;
run;
*********
Options "width" and "height" control the size of the outer edge of the entire graph. (Graph - the entire object, plot - inner rectangle bound by axes). Later on I'll be displaying multiple plots on one page and cropping outer margins. Since the scale labels (number of digits) vary from graph to graph, SAS resizes plots, while keeping graph size the same (500PX by 400PX). I want to control the size of inner plot rather than the entire graph.
Did you look at SGPANEL instead of SGPLOT?
Still not sure quite what you need but in SGPANEL you have some options to maintain row/column axis the same.
Have you looked at the SGPLOT ASPECT= option to play with ratios of wall areas?
proc sgplot data=sashelp.class; scatter x=height y=weight; run; proc sgplot data=sashelp.class aspect=1; scatter x=height y=weight; run;
Or moving to the Graphics Template Language provides more controls.
I'll clarify what I mean on the picture below:
Note how width of the graph (L) defined by the code (width= ) stays the same, while width of the plot (d) changes automatically to fit the content. I want to control width and height of the plot.
Maybe it is NOT what you want. @GraphGuy might have solution.
proc sgplot data=sashelp.class ;
scatter x=height y=weight;
xaxis offsetmax=0.5 valueshint;
yaxis offsetmax=0.1 valueshint;
run;
I think this issue has been discussed at
Options include SGPANEL or GTL.
One option (if you really do want to control the actual length of the axes ... not just the offset/origin so 2 graphs line up) is to use SAS/Graph gplot, which lets you directly specify the length of the axes. Here is an example:
goptions xpixels=400 ypixels=400 border cback=pink;
axis1 length=2.2in origin=(35pct,25pct);
axis2 length=2.2in;
proc gplot data=sashelp.class;
plot height*weight / haxis=axis1 vaxis=axis2;
run;
proc gplot data=sashelp.class;
plot name*weight / haxis=axis1 vaxis=axis2;
run;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Lock in the best rate now before the price increases on April 1.
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.