6
$\begingroup$

I need to export some (2D) graphs from mathematica in eps format (only, unfortunately). The graphs are of similar nature (plotted from our different functions), and I have used the PlotRange option to make all the graphs of equal size (in both x and y direction). However, while exporting, we get the exported files of slightly unequal size. This creates a problem while putting in some document, as when we scale it to the same size, the font size looks different (which, needless to say are same for everyone). I tried to use the ImageSize option, but definitely I am making some mistakes, as I am not getting the graphics ( or to be precise getting a small part of the graphics). So my question is, what is the best way to export all of them in a fixed size, say of 5cm x 4cm?

I use version 7. Advanced thanks for any help.

$\endgroup$
4
  • 1
    $\begingroup$ I think the answer is also ImageSize: Export["test.eps", Plot[Sin[x], {x, 0, 1}, ImageSize -> 200]] $\endgroup$
    – chris
    Nov 8, 2012 at 8:32
  • $\begingroup$ and I forgot to say you can specify e.g. Imagesize->{250,200} $\endgroup$
    – chris
    Nov 8, 2012 at 9:10
  • $\begingroup$ @chris ImageSize->{GoldenRatio*200,200} or any size in agreement with the AspectRatio specification might be even better to avoid the useless white border around the graph. $\endgroup$
    – VLC
    Nov 8, 2012 at 9:26
  • $\begingroup$ You wrote that you tried ImageSize and you use the same PlotRange. What can still change the appearance of the plots are different Labels on the Axes/Frame (since ImageSize is the size of the whole Plot not just the plot area). Also let me add this: If you want the picture to be 5cm wide the right ImageSize to use should be 5*72/2.54. Then you can set up the font size to whatever size you want (e.g. 10pt) and use the graphic without scaling. $\endgroup$
    – jens_bo
    Nov 8, 2012 at 9:59

2 Answers 2

4
$\begingroup$

To summarize all contributions,

Export["test.eps", Plot[Sin[x], {x, 0, 1},ImageSize -> 5*72/2.54*{GoldenRatio,1},
BaseStyle -> {FontSize -> 10, FontFamily -> "Helvetica"}]]

should produce a magnificent postscript file of the right size ;-)

it is truly magnificent

$\endgroup$
2
  • $\begingroup$ you can also add: BaseStyle -> {FontSize -> 10, FontFamily -> "Helvetica"} to get a sans-serif font in a size that matches the rest of your document. $\endgroup$
    – jens_bo
    Nov 8, 2012 at 18:46
  • $\begingroup$ This method no longer appears to work (using version 12.3). $\endgroup$
    – Karl
    May 30, 2022 at 22:32
1
$\begingroup$

I'm not sure if something happened between Mathematica version 7 and Mathematica version 12.3, but the accepted answer does not work for me.

Export[FileNameJoin[{"test.eps"}], 
 Plot[x, {x, 0, 1}, ImageSize -> 5*72], ImageSize -> 5*72]

Results in an image that is only 3.597 in. wide as identified by Inkscape. Doing the same with the ".svg" extension results in a file of the appropriate dimensions. Trying to rescale the dimensions by multiplying the ImageSize option by a factor of 1.39 resulted in a image that was 5.013 inches wide- slightly more than the desired 5.00 inches.

I think the most reliable method to obtain an accurately sized .eps file is to save it as an .svg, open it in another editor (Inkscape) and save it as .eps.

EDIT: I checked the output after saving as .eps in Inkscape, and the size did not stay constant upon saving. As far as I can see, there's no efficient way to accomplish this.

$\endgroup$

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.