MathGroup Archive 1997

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: crop .eps-files?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg9564] Re: crop .eps-files?
  • From: "P.J. Hinton" <paulh>
  • Date: Thu, 13 Nov 1997 01:40:26 -0500
  • Organization: Wolfram Research, Inc.
  • Sender: owner-wri-mathgroup at wolfram.com

Ketil.Danielsen at hiMolde.no wrote:
> 
> >
> > Ketil Danielsen wrote:
> > >
> > > I print a selected region (a plot) to a postscript file.  The postscript
> > > file fills a whole page and I want to zoom in on the interesting part
> > > (the graphplot) and include it in a latex  document as a normal figure
> > > that takes up only parts of the page (with the normal epsfbox[]
> > > sequence). How do I crop .eps files?  Do I have to know postscript?
> > >    Right now I convert to GIF, crop the GIF image  (in xv) and convertit
> > > back to .eps (using xfig) &  there must be a better way.  Any help
> > > appreciated. Is
> >
> > What version of Mathematica are you using?
> 
> v2.2
> 
> > What do you mean by the phrase "print a selected region".  Does this
> > mean that you select a cell in a Mathematica notebook and then use
> > the front end menu command File -> Print Selection?
> 
> yes.
> 
> > It almost sounds as if you want to export the graph as an EPS file
> > with an appropriate bounding box.  There are ways to generate these
> > types of files, but the steps you take will depend on the version
> > of Mathematica you are using.
> 
> I created one postscript file mathex.ps that you could
> look at on www.himolde.no/~kd/mathex.ps.gz.  (You write
> gunzip mathex.ps to uncompress, assuming you're in UNIX)
> If you could hint at ways to zoom in for this particular
> graph, by bounding box modification or other, I would be
> grateful.  I have had several e-mail from others who would
> want to know an answer to this, so a solution may have to be
> posted to a newsgroup or a relevant FAQ.

Under Mathematica for Windows or X, version 2.2, a graphic can be 
converted to an Encapsulated PostScript file using the following
procedure:

1) Use the kernel to regenerate the graphic so that the kernel
   has the Graphics object in its memory.

   Example:   gr = Plot3D[Sin[x] Cos[y], {x,0,2Pi},{y,0,2Pi}]

2) Use the kernel function Display[ ] to have the kernel write
   out a description of the image in abbreviated Mathematica
   Postscript.

   Example: Display["graphic.mps", gr]

3) Use the utility rasterps to convert the Mathematica
   Postscript into Encapsulated PostScript.

   Example: rasterps -file graphic.eps -format eps graphic.mps

   A version of rasterps comes with all Unix versions of 
   Mathematica 2.2.  It can be found in the Mathematica 2.2
   installation directory Bin/Display (the default path
   to this directory is /usr/local/math, but it may differ
   for your system).

   The MS-DOS equivalent, RASTERPS.EXE, does not appear on the 
   Mathematica 2.2 for Windows distribution media, but you can 
   get it from the MathSource website free of charge at URL:

  
http://www.mathsource.com/cgi-bin/MathSource/General/Systems/DOS/0203-634

REMARKS: 

Some later releases of Mathematica for Windows version 2.2 include a
menu command that allows you to export a selected graphic as EPS
completely independent of the kernel.  This uses an ImageStream
external filter.  This method works for simple graphics, but it may
produce some odd results for more complicated cases.

Mathematica 3.0 handles the export of graphics a little differently.
There is a front end menu command Edit -> Save Selection As -> EPS that
allows you to export graphics independently of the kernel, and this
works fine under Mathematica 3.0.1.x.  For users of  Mathematica
3.0.0.x, it can be fixed easily by downloading a new copy of
PostScriptHeader.tr at URL:

http://www.wolfram.com/support/Graphics/Formats/EPS/FrontEndFix.html

The kernel route has changed somewhat.  The functionality of 
RASTERPS.EXE has been integrated into a MathLink program called
psrender.  Display may now be called with an optional third  argument
that specifies the format

Example:	Display["graphicfile.eps", gr, "EPS"]

The kernel calls psrender automatically, so the process is  transparent.
The big drawback to this method is that you can  use only the Courier
and Mathematica-specific Math* fonts in the graphic.  All other fonts
will be substituted with Courier. I believe that with Mathematica
3.0.1.x, you can also use Times and Helvetica, but I am not absolutely
certain.

--
P.J. Hinton	
Mathematica Programming Group		paulh at wolfram.com Wolfram Research,
Inc.			http://www.wolfram.com/~paulh/ Disclaimer: Opinions expressed
herein are those of the author alone.



  • Prev by Date: mathematica and mining
  • Next by Date: Re: crop .eps-files?
  • Previous by thread: crop .eps-files?
  • Next by thread: Re: crop .eps-files?