BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Vic3
Fluorite | Level 6

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.

1 ACCEPTED SOLUTION

Accepted Solutions
GraphGuy
Meteorite | Level 14

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;

 

graph1.png

graph2.png

 

 

View solution in original post

10 REPLIES 10
Ksharp
Super User
Try
xaxis min= max=
Vic3
Fluorite | Level 6
Unfortunately min= max= only re-scales, but does not change plot dimensions.
Ksharp
Super User
Can you give us an example to illustrate your question ?
Vic3
Fluorite | Level 6

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.

ballardw
Super User

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.

 

 

Vic3
Fluorite | Level 6

I'll clarify what I mean on the picture below:

test1.jpg

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.

Ksharp
Super User

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;
GraphGuy
Meteorite | Level 14

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;

 

graph1.png

graph2.png

 

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 10 replies
  • 2779 views
  • 0 likes
  • 5 in conversation