Let us say I have a plot, for example that one:


enter image description here

and I would like to export it as a PDF in such a way that if I print the PDF in a A4 format (for instance), 1 "unit" on the plot will correspond to 1cm on the A4. So the $x$-axis above should measure exactly 5cm when printed on an A4. The curve can be rasterized.

Is there an accurate and robust way to do this?

PS: This can be useful if you want to print a map at a given scale, or plans, etc.


2 Answers 2


ImageSize has a form (still undocumented)

 ImageSize -> a -> b

to have a user units correspond to b printer's points.

So you can use

cm = 72/2.54;
Plot[x^2, {x, 0, 5}, AspectRatio -> Automatic, ImageSize -> 1 -> cm]

A paper ruler:

metricruler = Plot[0, {x, 0, 20}, 
  AspectRatio -> Automatic, 
  AxesOrigin -> {0, 0}, 
  PlotRangePadding -> 0, 
  PlotStyle -> None, 
  Axes -> {True, False}, 
  Ticks -> {Charting`ScaledTicks[{Identity, Identity}, "TicksLength" -> {.05, .02}],
  TicksStyle -> 16,
  ImageSize -> 1 -> cm] 

enter image description here

If you export as PDF and print you should get a paper ruler.

  • $\begingroup$ Dude! Woah! This is cool. What are the limitations of the units/inputs for b, in this case?? Wow!! $\endgroup$ Jul 25, 2019 at 4:16
  • $\begingroup$ @CATrevillian, i don't know of any limitations for b - any number should work, I think. $\endgroup$
    – kglr
    Jul 25, 2019 at 4:23
  • 1
    $\begingroup$ Oh I just suck at actually reading and did a skim, I see now you defined cm in the previous step. Still though! This is super awesome. I had thought you called an Entity or something like that. $\endgroup$ Jul 25, 2019 at 4:24
  • 1
    $\begingroup$ Just made the test: it's almost perfect, the rule measured about 20.07cm instead of 20cm. But the discrepancy might be due to the PDF reader and the printing procedure. In the next days, I'll try to adapt this helpful feature to generate an A4 or A3 pdf. Thanks! $\endgroup$
    – anderstood
    Jul 25, 2019 at 8:56

Looking at the documentation pages of FontSize and ImageSize, we see that both are given in printer's points, with 72dpi assumed.

This means that you can determine the appropriate settings like this:

$$\text{size for MMA}=\text{size in cm}\;\cdot72/2.54$$

As an example, the following produces a PDF with a size of an A4 paper, and the plot label is 1cm high:

  x^2, {x, 0, 5},
  PlotLabel -> "qfA",
  AspectRatio -> 5,
  LabelStyle -> FontSize -> 1*72/2.54,
  ImageSize -> {21, 29.7}/2.54*72
  • $\begingroup$ Mmh, I don't have MMA at hand right now, but I think this would only work if there is no axes or label. For example if the plot label is as long as the plot, 1cm on the plot will roughly correspond to .5cm on the paper. But I'll check. Thanks anyway. $\endgroup$
    – anderstood
    Jul 22, 2019 at 20:08
  • $\begingroup$ I'm not sure I get what you mean - The code in the answer generates a document of the desired size, and it has both a label and axes $\endgroup$
    – Lukas Lang
    Jul 23, 2019 at 7:25
  • $\begingroup$ I meant that your suggestion is not just "plot"-dependent: it is based on the scale of the whole graphic (plot + axes + ticks + labels + ...), not just on the surface covered by the coordinate system. Compare plot1 and plot2 with: plot2= Plot[ 5*x, {x, 0, 5}, PlotLabel -> "qfA", AspectRatio -> 5, LabelStyle -> FontSize -> 1*72/2.54, ImageSize -> {6, 29.7}/2.54*72 ] and plot2= Plot[ 5^3*x, {x, 0, 5^3}, PlotLabel -> "qfA", AspectRatio -> 5, LabelStyle -> FontSize -> 1*72/2.54, ImageSize -> {6, 29.7}/2.54*72 ]. $\endgroup$
    – anderstood
    Jul 24, 2019 at 7:59
  • $\begingroup$ Ahh, so you want 1 unit of the plot to equal 1cm? I thought you meant the number 1 in the tick mark for some (strange) reason $\endgroup$
    – Lukas Lang
    Jul 24, 2019 at 8:16
  • $\begingroup$ Indeed. I'll edit my question to make it more clear. $\endgroup$
    – anderstood
    Jul 24, 2019 at 9:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.