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

Hi - I am trying to produce scatter plots (4 per page in a PDF file) such that they are "square" rather than "rectangular" in shape (i.e. the x-axis is equal in length to the y-axis).  How can I make SAS do this (version 9.4) ?  Below is an example of the code for the 1st graph that appears in the top left corner of the page.

ODS PDF FILE="F:\graphs1_4.pdf";

ods layout start;

ods region x=0.25 in y=1.5 in width=3.75 in height=3.75 in;

proc sgplot data=cpet15 noautolegend;

  xaxis label="Time (min)";

  yaxis label="VE (L/min)";

  scatter x=t15_c_min y=ex_ve / MARKERATTRS= (symbol=circlefilled color=black size=3pt);

  scatter x=t15_c_min y=noex_ve / MARKERATTRS= (symbol=circle color=black size=3pt);

run;

ods layout end;

ods pdf close;

ods listing;

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

Look at the ASPECT= option in PROC SGPLOT.

PG

PG

View solution in original post

5 REPLIES 5
PGStats
Opal | Level 21

Look at the ASPECT= option in PROC SGPLOT.

PG

PG
Jay54
Meteorite | Level 14

The way to get a "real" equated plot is to use the GTL LayoutEquated container.  This will give you a graph where the mapping of the data to pixels on x and y axis are equal.  This is not hard.  Here is the code.

proc template;

  define statgraph equated;

    begingraph;

      entrytitle 'Blood Pressure';

     layout overlayequated / xaxisopts=(griddisplay=on)

                                        yaxisopts=(griddisplay=on);

     scatterplot x=systolic y=diastolic;

   endlayout;

  endgraph;

  end;

run;

proc sgrender data=sashelp.heart template=equated;

run;

A "poor man's" Equated plot can be obtained by using ASPECT option on SGPLOT procedure.  Note, this only makes the wall of equal size, but the actual pixel to data mapping may not be exactly equal.

proc sgplot data=sashelp.heart aspect=1;

  scatter x=systolic y=diastolic;

  xaxis grid;

  yaxis grid;

  run;

Notice in the first (GTL) graph, the axis tick interval is equal (50 units) on both axes and the number of pixels per grid is equal. 

In the second graph (SG), the wall is square, but the data spans about 200 units along x and about 100 units about Y.  The tick intervals are not equal.

PGStats
Opal | Level 21

I beg to differ. It is "not hard" ONCE you master proc template! How many days of work does that take? And anyone revising your work in the future will also need to spend that learning time.

Unless I am looking for something exotic, and a square graph area isn't that, I don't want to get into a new language layer.

PG

PG
Jay54
Meteorite | Level 14

It is perfectly reasonable to stay with the code you know.  As long as we understand that a plot with a square wall (equal X & Y axes lengths in pixels) is not same as an "Equated Plot".  An "Equated Plot" has the same mapping of data to pixels on both axes.  This ensures that an overlaid lineparm with slope=1,will display at 45 degrees.   Actual length of the axis need not be equal.

If what you want is an Equated Plot, you can approximate it with SGPLOT, as long as you ensure the data range on each axis is also in the same ratio as the ASPECT.  You should also watch out for axis offsets that are automatically set by the axis based on plot types.

rileynic
Calcite | Level 5

Hi - thanks so much for your help!  I was so set on making the graph "square" in the layout that I never even considered going back to the procedure to do it.  As it turns out, I am producing a number of graphs in this way, but the axes are never measured on the same scale, so the best solution for me is to use aspect=1 in the proc sgplot.  This worked like a charm for my situation & I really appreciate the discussion!!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 3505 views
  • 6 likes
  • 3 in conversation