I am not at all a computer graphics expert, but it seems that portable document format (PDF) files have a "native size," even though they may (and usually do!) contain vector graphics that can be scaled essentially infinitely without loss of quality.
In Mathematica, the ImageSize
option in graphics and plotting commands like Graphics
, Plot
, and ListPlot
allows one to specify the size of images such as graphics and plots. One way to use the ImageSize
option is to simply specify a width $w$. The image will be given that width and the image's height will be automatically chosen so as to maintain the image's AspectRatio
(which, for plots, has the default 1/GoldenRatio
).
Now, in the documentation for ImageSize
(see the Details section), it is stated that one possible specification for width $w$ (and for height $h$) is $72 di$, which specifies $di$ inches (before magnification), according to the Documentation. This means that if I want an image (for example, a ListPlot
) to be $di$ inches in width, I just need to use the option ImageSize -> (72*di)
within the ListPlot
. (I'm not certain, but it may be necessary to round the result to an integer, since I'm not sure if ImageSize
accepts fractional/decimal arguments. If so, then I can just use ImageSize -> Round[72*di]
).
So here's an example. Suppose that I'm told by a publisher that my image should be 8 inches wide. So I use ImageSize -> (72*8)
in ListPlot
. Then I customize my ListPlot
in a variety of ways: I use the BaseStyle
option to set the font size and family and I use Disk[]
shapes as the PlotMarkers
. I play with the parameters until my plot looks nice. For example:
xdata = Range[0, 0.05, 0.00115];
ydata = Sin[160*xdata];
pmSize = 10;(* size of PlotMarkers *)
pm = Graphics[{Red, Disk[]}, ImageSize -> pmSize];(* PlotMarkers *)
imgSizeInInches = 8;
imgSizeInPixels = Round[72*imgSizeInInches];(* ImageSize *)
pl = ListPlot[Transpose[{xdata, ydata}],
PlotRange -> {-1.1, 1.1},
Frame -> True,
FrameLabel -> {"x (unit)", "y (unit)"},
FrameStyle -> Thickness[Medium],
AxesStyle -> Thickness[Medium],
BaseStyle -> {26, FontFamily -> "Arial"},
PlotMarkers -> pm,
ImageSize -> imgSizeInPixels]
which gives this output:
Now I export to a PDF file called "example.pdf":
Export["example.pdf", pl, "AllowRasterization" -> False]
I open this PDF in Adobe Acrobat. Adobe Acrobat tells me (see the status bar at the bottom left) that, as promised, the image is 8 inches wide:
Yea! I am pleased, and so is my publisher: the PDF file's native size is 8 inches wide!
Now, however, suppose that the publisher changes its mind and now wants the PDF image to be natively 5 inches wide instead. My first thought is to simply set ImageSize
to 72*5
. That will make the width of the image 5 inches. I do this by simply setting imgSizeInInches = 5;
in my code:
xdata = Range[0, 0.05, 0.00115];
ydata = Sin[160*xdata];
pmSize = 10;(* size of PlotMarkers *)
pm = Graphics[{Red, Disk[]}, ImageSize -> pmSize];(* PlotMarkers *)
imgSizeInInches = 5;
imgSizeInPixels = Round[72*imgSizeInInches];(* ImageSize *)
pl = ListPlot[Transpose[{xdata, ydata}],
PlotRange -> {-1.1, 1.1},
Frame -> True,
FrameLabel -> {"x (unit)", "y (unit)"},
FrameStyle -> Thickness[Medium],
AxesStyle -> Thickness[Medium],
BaseStyle -> {26, FontFamily -> "Arial"},
PlotMarkers -> pm,
ImageSize -> imgSizeInPixels]
...which gives this output:
When I export to a PDF file using Export["example.pdf", pl, "AllowRasterization" -> False]
and open the resulting file in Adobe Acrobat, Adobe Acrobat confirms that the native width of the image is 5 inches:
But now the image is crammed -- the size of the image decreased, but the sizes of the font and the plot markers did not.
So, my question is: is there any way to simply scale the image so that the PDF file's "native" size decreases while also proportionally decreasing the size of the text, plot markers, etc? In that way, the entire image would "shrink" proportionally -- although without loss of quality since the image is a vector graphic!
Please not that I do not want to rasterize the image; I would like to keep the image as a vector graphic. Thank you for any help you can give with this confusing issue.