Saving Postscript Graphics from Mathematica

Robert A. Stine
Department of Statistics, The Wharton School
University of Pennsylvania
Philadelphia, PA  19104-6302

Printing Functions

To save the Mathematica graphics to a file, you simply need to build a display function that will save them as a postscript file.  It may be possible to automatically get the desired font size,
but I just kludged it by setting it manually.

$DefaultFont = {"Courier", 18}

myPrint[fig_,num_] := 
  (With[{name = StringJoin["graph", ToString[num],".ps"]},
         Print["Saving graph in file ", name];
         Display[
           StringJoin["!psfix -epsf -width 6.5 -height 4 -stretch >",
                       name],
           fig]; fig])

Example

Save the plot you want to save as a variable.  Note that the big font that seems "ugly" now will print fine later.  Again, there's probably a better way, but this works!

thePlot = Plot[x^2, {x,-2,4}, AxesLabel->{"X Axis", "Y Axis"}]

The next command (as defined in the function above) saves the as an encapsulated Postscript file called "graph1.ps".

myPrint[thePlot,1]