R-beta: postscript in R and R
Douglas Bates
bates at stat.wisc.edu
Thu Apr 30 22:15:31 CEST 1998
Thomas Lumley <thomas at biostat.washington.edu> writes:
> On Sat, 25 Apr 1998, Helgi Tomasson wrote:
> > I am creating postscript-graphics in R. When I import them into
> > a LATEX document it is impossible to get the caption close
> > to the figure. I run the same program in Splus, and no problem
> > of getting the caption just below the figure. Another thing,
> > the ps file that S created is only 10% of the size of the file
> > that R created. What is wrong? Are there some parameters to
> > be set?
>
> I haven't noticed this problem with figures from R in LaTeX. Which version
> of R is it, and do you have a specific example?
>
> You can always fix the amount of space a PostScript file takes up in LaTeX
> by altering its bounding box. The bounding box is given by a line
> %%BoundingBox: 46 169 549 673
> near the top of the PostScript file, and it specifies the amount of the
> page that the graph actually occupies, measured in 72ths of an inch, from
> the lower left corner of the paper. The four numbers are the distances to
> the left, bottom, right and top margins of the picture.
>
> The \epsfig{} command in LaTeX lets you specify a new bounding box if the
> one in the file is missing or incorrect, or you could edit the file.
>
> Of course it's better if the bounding box is right to begin with.
Sorry to get into this late - I have been off at a conference.
The Aladdin distribution of ghostscript contains a script called
ps2epsi that re-calculates and inserts a tighter bounding box. It
does this essentially by rendering the postscript code on a raster
then determining a minimal bounding box for the raster.
A disadvantage of using ps2epsi is that it also includes the raster
image in the file so the figure can be rendered in a word processor,
for example. If you don't need that you can strip the file down a bit
using a script that Bill Venables and I called ps2eps.
#!/bin/sh
infile=$1
if [ $# -eq 2 ]
then
outfile=$2
else
outfile=`basename ${infile} .ps`.eps
fi
ps2epsi $infile /tmp/X$$.epsi
sed -e '/^%%BeginPreview/,/^%%EndPreview/d' -e '/^%%EOF/d' < /tmp/X$$.epsi > $outfile
rm -f /tmp/X$$.epsi
exit 0
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list