At SAS Global Forum, and again at PharmaSUG, we had the pleasure of attending many papers and presentations on various topics that included graphs in the power point decks or in the papers. More often than not, the graphs exist along other text, and occupy a smaller part of the screen or page. These presentations include graphs created by ODS graphics, either as automatic graphs from Base and STAT procedures, or by SG procedures.
Often, the natural inclination is to fit the default sized graphs created by the procedure into a smaller space in the presentation. All graphs (with very few exceptions) created by ODS Graphics have a size of 640 x 480 pixels. This is the same as 6.66 x 5 inches at the default 96 dpi. When a graph like this is inserted into a smaller space in a Powerpoint slide or in one column of a Word doc, the graph is shrunk to fit the space. In such cases, a default size graph would look like this:
The above graph is captured from the screen from a Word document. When a 6.66 inch wide graph is shrunk to fit a 3.25 in wide space, everything is scaled down by a factor of (3.25 / 6.66) = 0.488. As we can see, all the elements of the graph are scaled down, including the text so an 8pt. font is now displayed effectively at 4pt. which is quite unreadable to many eyes. A similar effect is can also be seen to varying degrees in various papers presented at SGF 2012.
My solution is to render the graph at its expected size on the page using a high dpi. In a two column document, each column is about 3.25 inches. So, I render the graph with a width of 3.25 inches at 300 dpi. When this graph is inserted into a 3.25 wide region, we get this:
Here are the options you need to get this :
ods listing image_dpi=300; ods graphics / width=3.25in;
As you can see, now the graph fits "as is" in the space, and the text elements are clearly readable. This effect is by design, and not by accident. Internally, the default "design" size of all ODS Graphs is 640 x 480 pixels. At the default dpi of 96, this translates to a graph of about 6.66 x 5 inches. However, when this graph is rendered at a smaller "render" size of 3.25 inches, all elements of the graph are scaled by a non-linear factor = (3.25 / 6.66) ** 0.25 = 0.83. This is done by the procedure, so now the 8pt font is rendered at about 6.6pt, which is much more readable. The DPI value of the image is inserted into the PNG file, so Powerpoint and Word know how to display the image correctly.
Here is another example of a QTc graph, inserted into a 3.25 inch wide space, with a graph rendered using default settings, and another graph rendered with a width of 3.25 inches at 300 dpi.
Default rendering:
Rendered with width=3.25in and 300 dpi:
Note: There are two types of scaling going on in this situation.
- Linear image scaling is done by Word to fit an image into the space available.
- Non linear graph scaling is done by ODS to render a design-size graph into render-size image.
In the examples above, the 1st case uses only image scaling to squeeze a 6.66 inch graph into a 3.25 inch space. In the 2nd case, we use only graph scaling as we rendered the graph to the right width of 3.25 inches, so no image scaling was applied.
Sometimes, when a graph is very busy, using a width of 3.25 inches can make the fonts relatively too big. You can use a combination of the image scaling and graph scaling to achieve an intermediate result. If you render the graph to a width of 4 inches, and then add it to a 3.25 inch space in the doc, here is what you get:
A 4 in wide graph at 300 dpi in 3.25 inch space:
In this case the font sizes are somewhere between the first two examples, and imho, well balanced. You can use this technique to fine tune the graph for maximum quality and readability. These graphs are rendered using SAS 9.3, but this scaling technique also applies to SAS 9.2 graphs.
Full SAS code: Graph_Size_SAS93





























