BookmarkSubscribeRSS Feed
samp945
Obsidian | Level 7

Hello all,

 

I am trying to write SGPLOT code which accomplishes the following:

1) High resolution (300 DPI)

2) Produces PNG output which is 6.5" in height

2) Uses non-scaled fonts of specified sizes

 

Here is the relevant code which I have written:

ods listing gpath='\\figures\' IMAGE_DPI=300;
ods graphics / RESET
		NOSCALE height=6.5in imagename="Figure1" outputfmt=PNG;
Footnote justify=left font="Times New Roman" height=12pt "Figure 1";
Proc sgplot Data=Figure1 noborder;

The resulting PNG file is the correct height and DPI, but the fonts are scaled to be slightly larger than specified, even though the NOSCALE option is used. Strangely, the window output display is as desired and does not contain scaled fonts.

 

If I produce the figure at the default DPI of 96 (by removing the "IMAGE_DPI=300" code), then the resulting PNG file is the correct height and the text is not scaled. However, the default DPI of 96 is not acceptable for my purposes. As soon as I specify a higher DPI (150, 200, 300, etc), the fonts are scaled to be larger than specified.

 

What am I doing wrong? Thanks for reading and any help you can provide!

6 REPLIES 6
ballardw
Super User

Just how much is it scaled? Does it happen with the default font for the current style?

Only the Footnote text or in other places as well?

 

If the topic isn't sensitive you should include an example of the rescaled text in an image. Click on the Camera icon above the message window and then drag one of the images from your file manager to the drop area.

 

samp945
Obsidian | Level 7

Thanks for your reply, ballardw.

 

The text is not scaled very much and is most noticeable for the footnote text (actually the title but placed at the bottom). Unfortunately, the footnote/title is the only text that I definitely need in exactly 12-point font size. Other text also appears to be scaled. The scaling happens with the default font as well as the Times New Roman footnote font I have specified.

 

Unfortunately the data is sensitive so I can't post the original graphics, but I have reproduced the bottom of the graph with an example title and attached here.

 

This first image is the default 96 DPI and the footnote text is exactly 12-point font. Notice where it ends (just below the 900 mark on the x-axis).

Not Scaled.png

 

This second image is 300 DPI and the footnote text is larger than 12-point font. Notice that it ends beyond the 1,000 mark on the x-axis.

 

Scaled.png

 

Thanks for your help!

samp945
Obsidian | Level 7

After some more investigating it appears that no combination of font size, NOSCALE, and DPI actually produces a 12-point font that exactly matches a 12-point font in Word. I previously thought that the default 96 DPI and font size 12 was an exact match, but it actually is not. I have found that when requiring 300 DPI and using the NOSCALE option that an 11.5-point font size is a close but not exact match.

 

Is the slight discrepancy in font size between SGPLOT and Word expected behavior?

ballardw
Super User

First a generic Microsoft comment: why would you assume that Word is correct?

 

How are you comparing these? If you paste an image into Word you want to double check that the size after becoming part of the Word document is the same size you intended. I seem to remember having an issue with pasting images and having the size modified by a small amount in some versions of Word. OR that the ratio of Height to Width changes. If you are looking at things on different monitors that may have an impact as well.

 

 

samp945
Obsidian | Level 7
You make some excellent suggestions, ballardw.
I guess I didn't assume that Word was correct per se, only that the font size output from SAS does not exactly match the font size output from Word. I am comparing output on the same monitor as well as printed copies (which appear to match the monitor).
When I paste the images into Word (with gridlines turned on to gauge size and position), the size and dimensions of the pasted images do not appear to change. Also, when I right-click the image and check the dimensions, they are as expected (exactly 6.5" high with no scaling and the aspect ratio locked). So as far as I can tell, Word is not changing the images after being pasted.
I'm mostly confused about why changing the DPI in SGPLOT seems to slightly change the font size, even when the NOSCALE option is used. I'm also confused why the graphs displayed in the SAS output window appear to be scaled correctly and do not change when the DPI is changed but the PNG images output seem to be scaled differently depending on the DPI.
GraphGuy
Meteorite | Level 14

The other suggestions/observations are valid points, but I agree this is the key mystery: "why changing the DPI in SGPLOT seems to slightly change the font size".

 

Perhaps the developers could check the underlying calculations(?)  @DanH_sas ?

 

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!
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
  • 6 replies
  • 613 views
  • 0 likes
  • 3 in conversation