Skip to content

bounding box in PostScript

6 messages · Brian Ripley, (Ted Harding), Berwin A Turlach +1 more

#
When a graph is saved as PostScript, the bounding box is often too big.
A consequence is that when the graph is included in a LaTeX document,
the spacing does not look good.
Is this a recognized problem? Is someone working on it? Could I help?

David
#
On Mon, 17 Apr 2006, David Allen wrote:

            
It's not really true.  The bounding box is of the figure region, and it is 
a design feature.  If the figure `region' that is too big for your 
purposes you need to adjust the margins.

Alternatively, there are lots of ways to set a tight bounding box: I tend 
to use the bbox device in gs.  But that often ends up with figures which 
do not align, depending on whether text has descenders.
#
On 17-Apr-06 Prof Brian Ripley wrote:
Ghostscript's BBox resources tend to suffer from this problem,
since for some reason as Brian says it may not properly allow
for the true sizes of characters. I once tweaked ps2eps to
correct (more or less) for this.

But nowadays, to get it exactly right, I use gv (ghostview
front end) to open the EPS file, and set "watch" mode:

  gv -watch filename.eps

If it doesn't automatically give the "BoundingBox" view, you
can always select this from the top menu. This ensures that
the frame of the gv window is the same as the BoundingBox.

Then open the EPS file for editing, and look for the

  %%BoundingBox llx lly urx ury

line (it may be near the beginning, or at the end -- which
will be flagged by a line

  %%BoundingBox: atend

near the beinning).

Here, llx, lly, urx, ury are integers giving the coordinates
(in points relative to the page origin) of the lower left,
and upper right, corners of the bounding box.

Now you can change the values of these. Each time you change,
save the edited file. Because gv is in "watch" mode, it will
re-draw the page whenever the file changes. Thus you can adjust
the bounding box until it is just as you want it.

Best wishes,
Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 17-Apr-06                                       Time: 23:05:29
------------------------------ XFMail ------------------------------
#
G'day David,
DA> When a graph is saved as PostScript, the bounding box is often
    DA> too big.  A consequence is that when the graph is included in
    DA> a LaTeX document, the spacing does not look good.  Is this a
    DA> recognized problem? Is someone working on it? Could I help?
How exactly are you saving the graph as PostScript?

I guess the problem is due to the fact that you save the PostScript
picture on a paper according to your default paper size (which is "a4"
for me).  To create PostScript pictures with reasonalbe tight bounding
boxes that are suitable to be included in a LaTeX document you should
specify `paper=special' and then define your plotting area via the
'height' and 'width' argument.

Hope this helps.

Cheers,

        Berwin

========================== Full address ============================
Berwin A Turlach                      Tel.: +61 (8) 6488 3338 (secr)   
School of Mathematics and Statistics        +61 (8) 6488 3383 (self)      
The University of Western Australia   FAX : +61 (8) 6488 1028
35 Stirling Highway                   
Crawley WA 6009                e-mail: berwin at maths.uwa.edu.au
Australia                        http://www.maths.uwa.edu.au/~berwin
#
On Tue, 18 Apr 2006, Berwin A Turlach wrote:

            
To clarify, the bounding box is always for the device region, not the 
paper, even when (as by default) the device region is centred on the paper 
with 0.25" margins.  The problems with just using postscript() are

1) The plot is rotated (the default for 'horizontal').
2) The text is too normally small for inclusion in other documents, since 
the size is chosen to be appropriate for a whole-page plot.
3) The header may cause the including application not to use the bounding 
box, but for example the DocumentMedia or some inbuilt assumption.

I am pretty sure the perceived problem is the margins on the figure 
region, and the appropriate way is to reduce those vai par(mar=).  (I do 
that for all my books.)