In practice, the range of the X axis might not exactly equal the range of the Y axis. If your X and Y ranges are not exactly equal, read on. For example, if the range of the Y variable is 2, you can use ASPECT=2 to set the wall area to be twice as high as it is wide.īecause the range of the X variable equals the range of the Y variable, and the margins in the wall area (set by using the OFFSETMIN= and OFFSETMAX= options) are also equal.
This technique also works for other aspect ratios. You can adjust the width of the graph to get rid of the extra space. Notice that graph has a lot of white space to the left and right of the wall area. The wall area is approximately 370 pixels in both directions. Proc sgplot data=S aspect= 1 /* set physical dimensions of axes equal */Īlthough the graph size has not changed, the wall area (which contains the data) is now square. However, in SAS 9.4 you can use the ASPECT= option on the PROC SGPLOT statement to tell PROC SGPLOT to make the wall area (data region) square, as follows: For example, you could start the process by submitting ODS GRAPHICS / WIDTH=400px HEIGHT=400px.
#X AND Y AXIS ADJUSTMENT CREATION WORKSHOP TRIAL#
You had to use trial and error to adjust the width of the graph until the wall area looked approximately square. Prior to SAS 9.4, PROC SGPLOT did not provide an easy way to set the aspect ratio of the wall area. You can see that each cell in the grid represents a square with side length 0.5, but the cells do not appear square on the screen because of the aspect ratio of the graph. However, because of labels and titles and such, the region that contains the data (also called the wall area) is about 555 pixels wide and 388 pixels tall, which is obviously not square. The graph area occupies 640 x 480 pixels. You can click on the graph to see the original size. Ods graphics / reset /* use default width and height */ title "Default Graph: 640 x 480 pixels" The default graph has a 4:3 ratio of width to height, so when you create a scatter plot, the physical lengths (in pixels) of the X and Y axes are not equal:ĭata S /* XRange = YRange = */ input x y 1 - 1 - 0.75 - 0.5 - 0.5 - 0.75 - 0.25 0 0 0.5 0.25 - 0.25 0.5 0.75 0.75 0.25 1 1
Therefore the range of each variable is 1. The X and Y variables both have a minimum value of 0 and a maximum value of 1. However, the physical dimensions of the axes (in pixels or centimeters) depends on the titles, labels, tick marks, legends, margins, font sizes, and many other features.įor example, the following data has two variables. When you request a scatter plot, the minimum and maximum value of each coordinate is used to determine the range of the axes.
#X AND Y AXIS ADJUSTMENT CREATION WORKSHOP PDF#
Usually the width and height of a graph does not depend on the data.īy default, the size of an ODS statistical graphic in SAS is a certain number of pixels on the screen or a certain number of centimeters for graphs written to other ODS destinations (such as PDF or RTF). You can use the ASPECT= option in PROC SGPLOT and the OVERLAYEQUATED layout in the Graph Template Language (GTL).ĭata scale versus physical measurements of a graph This article presents two ways to create ODS statistical graphics in SAS in which the scale of the data is preserved by the plot. It is also important if you are plotting polygons and want a square to look like a square. This is important when you want to visualize the distance between points, as in certain multivariate statistics, or to visually compare variances. For example, if the ranges of the X and Y variables are equal, it can be useful to display the data in a square region. When creating a statistical graphic such as a line plot or a scatter plot, it is sometimes important to preserve the aspect ratio of the data.