Skip to content

Can't save a graph to pdf in R for MacOS

4 messages · Sébastien Plante, p.b.pynsent@bham.ac.uk, Brian Ripley

#
Hi,

I am using R 1.7.1 (carbon) for MacOS and I am running it on MacOS X 
10.2.6. When I send a graph to the pdf device (or any other devices), I 
get a zero KB file name "Rplots.pdf".

Before sending my graph to the output, I did:

 > dev.off()
 > pdf()
 > boxplot(... my graph commands...)
 > dev.off()

Is this the correct procedure?  I did the same procedure on another PC 
running Linux (R 1.6) and it work well.

Please help!

Thanks,

S?bastien Plante
1 day later
#
I do not have an R solution but use eps2pdf (a Perl script)
This can be installed by Fink
http://sourceforge.net/projects/fink/.
On Wednesday, June 25, 2003, at 03:41 am, S?bastien Plante wrote:

            
#
On Thu, 26 Jun 2003, p.b.pynsent wrote:

            
eps2pdf runs GhostScript: so does the R device driver bitmap().  Does the
latter work on your system?  If so it would save you some steps.

  
    
#
Thank you for your helpful comments. You have indeed saved me time, 
when I started to document my reasons for the more tortuous route for 
generating pdf files they would seem now to be unnecessary.
Thus I have misled S?bastien Plante as pdf() works fine on my MacOS X 
10.2.6 but R 1.7.0.
Originally I had immense problems trying to get transparent 
backgrounds. e.g. ps.options(bg = "transparent") did not seem to work.
However this does work consistently now in using both eps and pdf 
formats. Although,

postscript("pdftest.eps")
ps.options(bg = "white")
... plotting bits
dev.off()

will produce an eps file with a transparent background the first time 
it is run after starting R but white on subsequent runs during the same 
R session. Whilst the sequence

ps.options(bg = "white")
pdf("pdftest.pdf")
.... plotting bits
dev.off()
will consistently produce a white background.
I imagine this is of little consequence to most people.

Lastly to answer your question about the R device driver bitmap(), I 
tried,
  bitmap("pdftest.pdf", type = "pdfwrite")
and got
Error: couldn't find function "bitmap"
so I presume NO.

Paul


 >
On Thursday, June 26, 2003, at 12:32 pm, Prof Brian D Ripley wrote:

            
Dr. P. B. Pynsent,
Research and Teaching Centre,
Royal Orthopaedic Hospital,
Birmingham, B31 2AP, U.K.