Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I am generating a complicated graphics with Mathematica, but with objects of given sizes (e.g. a line of length 1 inch, between two points). I want to make sure that when I export the graphics, e.g. as pdf, and then when I print it, the line length on paper will be one inch, without additional tweaking (assuming no scaling when printing).

share|improve this question
1  
Please see this question: stackoverflow.com/q/6203586/618728 –  Mr.Wizard May 11 '12 at 9:54
1  
Also this one on mathgroup: Controlling scale of Graphics on paper –  Yves Klett May 11 '12 at 10:57

4 Answers 4

(I posted a similar answer on MathGroup recently.)

Here's an alternative to the other very good answers you already received.

If you need high accuracy, I recommend exporting to DXF. DXF is a format used by CAD applications requiring precision. Then you can use one of the many DXF-viewers or CAD programs to print to precision. (There seem to be a number of free programs available.)

Please see this answer of mine as well, where I described a little bit how Mathematica treats different units and how one can export figures to size.

share|improve this answer
    
I agree that DXF comes in handy in the CAD area and export is to scale by default, but I feel the possible higher precision as such may only be useful in very special cases. One possible catch is the Mathematica DXF format, which does not go down well with some programs (but DXF seems to be quite a nest of snakes versionwise anyway). –  Yves Klett May 11 '12 at 13:45
    
@Yves I don't have much experience with DXF. I did try exporting to DXF and verified that the sizes are preserved, but I haven't used the format otherwise. Are you saying that you ran into problems when using it? (BTW this answer was meant to be complementary to the others, I'll update to make it clear) –  Szabolcs May 11 '12 at 13:54
    
Mathematica exports 3D DXF data, but some CAD/CAM programs (e.g. CATIA) do not work properly with that. Cannot say who is mistreating the spec, though. Otherwise exported DXFs seem fine (I ran across some problems when exporting non-convex polygons which are not always triangulated properly, but that is not DXF-specific). –  Yves Klett May 11 '12 at 14:18

Quite redundant after the other answers and links, but I use something like this for vector-based technical drawings and CNC data (using mm as unit). This is not foolproof as it might e.g. screw up with conflicting options and such, so make sure to check the output.

Important: SetPlotRange for your graphics explicitely:

gfx = Graphics[Line[{{10, 10}, {110, 10}, {110, 110}}], 
  PlotRange -> {{0, 200}, {0, 200}}]

ExportScaled[filename_, gfx_, format_: {210, 297}, opts___?OptionQ] :=
  Module[{mm}, mm = 72/25.4;
  Export[filename, 
   Show[gfx, ImageSize -> format*mm, ImageMargins -> 0, 
    ImagePadding -> None, AspectRatio -> Automatic], opts]]

For proper scaling, your graphics´ PlotRange and the exported ImageSize need to correspond.

ExportScaled["test.pdf", gfx, -Subtract @@@ (PlotRange /. 
     Options[gfx, PlotRange])]

Below: Output measured in Acrobat (Again: It is usually a good idea to test a few cases by measuring them with Ghostview, Acrobat or such. Works just as well for EPS export).

Mathematica graphics

share|improve this answer
    
Thank you, that is helpful. The actual graphics I have is larger than the page size. How do I divide it to a few pages without scaling ? –  Yigal Meir May 11 '12 at 20:04
    
@YigalMeir You can set PlotRange accordingly, i.e. with an offset of your choice. Example: PlotRange -> {{0+50, 200+50}, {0-40, 200-40}}. –  Yves Klett May 12 '12 at 9:09

Your question isn't very specific, so here is a generic example from another question

From the documentation for ImageSize:

The following settings can be given:

72di di inches (before magnification)

Suppose we want to give sizes in centimeters. We establish a scale:

cm = 72/2.54;

And we give the ImageSize in this scale, also making sure to set PlotRangePadding -> None. This gives a 1cm x 1cm orange square on a 19cm x 28cm field.

g = Graphics[{Rectangle[{0, 0}, {19, 28}], Orange, 
    Rectangle[{0, 0}, {1, 1}]}, PlotRangePadding -> None, 
   ImageSize -> {19, 28}*cm];

When exporting you can give a specific resolution to use. For printing 300dpi may be appropriate:

Export["print.tif", g, ImageResolution -> 300]
share|improve this answer

You can specify ImageSize in inches. From docs > ImageSize> MoreInformation:

 Specifications for both width and height can be any of the following: 
     ...
     72di         di inches (before magnification)
     ... 

Examples:

Row[{Plot[{Sin[x], Cos[x]}, {x, -2 Pi, 2 Pi}, Frame -> True, 
AspectRatio -> 1/GoldenRatio, ImageSize -> 72 2], 
Plot[{Sin[x], Cos[x]}, {x, -2 Pi, 2 Pi}, Frame -> True, 
AspectRatio -> 1/GoldenRatio, ImageSize -> 72 3], 
Plot[{Sin[x], Cos[x]}, {x, -2 Pi, 2 Pi}, Frame -> True, 
AspectRatio -> 1/GoldenRatio, ImageSize -> 72 5]}]

enter image description here

EDIT: Per Mr.Wizard's suggestion, adding various Paddings in inches:

inches = 72; 
Panel@ Plot[{Sin[x], Cos[x]}, {x, -2 Pi, 2 Pi}, Frame -> True, 
PlotRangePadding -> {0.001 inches, 0.001 inches}, 
ImagePadding -> 0.3 inches, ImageMargins -> 0.3 inches, 
AspectRatio -> 1/GoldenRatio, ImageSize -> 5 inches]

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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