Message Boards Message Boards

How to produce a graphic with absolute size?

Posted 10 years ago

Does anyone know how to get Mathematica to output a graphic at an absolute size?

We can specify sizes in printers points, so 72 x n = n inches. How, for example, could I draw several 3 inch diameter circles at absolute positions in an 8.5 x 11 inch graphic, then export it to a tif or jpg or pdf in such a manner that when it is printed it will be exactly as designed?

Best, David

POSTED BY: David Keith
4 Replies
Posted 10 years ago

Thank you -- that helps. I've had good success with this.

POSTED BY: David Keith

This is a good question, and there's a lot to say here that hasn't been mentioned ...

I have written a bit about this here.

First please notice that Dr. Blinder's solution does not produce a 3 inch circle when exported to PDF and printed at 100% size. (Physical units are encoded in PDFs.) The diameter is about 0.7 in.

The following does:

inch = 72;
cm = inch/2.54;  (* for people who, like me, like centimetres better *)

g = Graphics[Circle[{0, 0}, Offset[3/2 inch]]]
Export["~/Desktop/circle.pdf", Show[g, ImageSize -> {8.5 inch, 11 inch}]]

This will produce a PDF which has a size of precise 8.5 by 11 inches and has a 3 inch diameter circle in the middle.

The key points to achieve this were:

  • I used Offset coordinates to specify the size. Offset coordinates represent a physical size in printer's points and do not scale when the graphics are resized (try it!). For example, all text sizes are treated as offset coordinates, which is why resizing Mathematica figures doesn't resize the text. This is actually convenient for publication figures where we can specify the target font size, e.g. 10 pt, and Mathematica will honour that (regardless of the figure size). Other coordinate types available: Scaled, as a fraction of the figure size, or standard plot coordinates.

  • When exporting, I specified the figure size explicitly. To make sure that the size will be correct with all versions of Mathematica, it's necessary to add the ImageSize to the Graphics with Show rather than specify it in Export directly.

When printing this, make sure scaling is set to 100% in your PDF reader. Do not allow it to rescale the PDF (which many readers will automatically do to make sure it fits the paper and fills out the paper).

Do not use raster formats like TIFF or PNG when exporting. While they can encode physical sizes, not every program respects this. Please use PDF only, which does reliably encode physical sizes, and practically every PDF reader has an option to respect these sizes while printing.

POSTED BY: Szabolcs Horvát
Posted 10 years ago

Thanks -- exactly what I needed.

POSTED BY: David Keith

Try this:

a = 72; Graphics[{Circle[{0, 0}, 3 a]}, PlotRange -> {{-4.25 a, 4.25 a}, {-5.5 a, 5.5 a}}]
POSTED BY: S M Blinder
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract