[R] Printing ps pictures with transparent b'ground
Prof Brian Ripley
ripley at stats.ox.ac.uk
Thu May 6 08:00:55 CEST 2004
It is the background when the picture is drawn that matters. We do have
(and recommend) dev.copy2eps for copying to eps files for inclusion in
documents, but my first sentence still applies. You are copying exactly
what you plotted on screen.
If you want a solid background on your .eps file (unusual, and I think you
should be doing it in the including application), you need to produce
the plot to copy exactly as you want copied. If you are copying from an
x11() device, set bg="white" on that device (via par(bg="white") before
plotting).
On Thu, 6 May 2004, Peter Dunn wrote:
> I wish to create a ps file of a picture produced in R.
> With my limited R, I see two ways:
> 1. Print direct to the postscript device
> 2. Print to the screen, and save to ps using dev.print.
Do you mean `plot', not `print' here?
> I want a white (not transparent) background. Option
> 1 above works fine, but 2 does not: even when I say I
> want a white background, I get transparent; perhaps I
> misread the help files.
>
> Here's some R code:
>
> ### Method 1
> ### - print straight to postscript device
> postscript(horizontal=FALSE,
> onefile=FALSE,
> bg="white",
> width=4,
> height=4,
> paper="special",
> file="testfile.eps" )
> curve( dnorm, from=-3, to=3)
>
> dev.off()
>
> ### Method 2
> ### - print to screen, and save using postscript
>
> x11(width=4, height=4)
> curve( dnorm, from=-3, to=3)
>
> dev.print( postscript,
> horizontal=FALSE,
> onefile=FALSE,
> bg="white",
> width=4,
> height=4,
> paper="special",
> file="testfile2.eps" )
>
>
> I then want to place these files in a LaTeX prosper document
> for a presentation. A typical (minimal) prosper file is:
>
> \documentclass[pdf,colorBG,slideColor,whitecross]{prosper}
>
> \begin{document}
>
> \begin{slide}{Print to \textsc{ps} direct}
> \includegraphics{testfile.eps}
> \end{slide}
>
> \begin{slide}{Print to screen first}
> \includegraphics{testfile2.eps}
> \end{slide}
>
> \end{document}
>
>
> The whitecross class provides a blue background for the
> presentation. testfile.eps appears with a white background
> on the slides, but testfile2.eps has a transparent
> background.
>
> I'd apprecaite if someone could explain why the two are not equivalent,
> or how I can coerce the second option to have a white background? Or
> even explain my misunderstandings (assuming (with high probability)
> that I have some).
>
> Thanks.
>
> P.
>
> > version
> _
> platform i686-pc-linux-gnu
> arch i686
> os linux-gnu
> system i686, linux-gnu
> status
> major 1
> minor 8.1
> year 2003
> month 11
> day 21
> language R
>
>
>
>
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list