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!
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.
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).
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.
Thanks for your help!
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?
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.
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 ?
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.