Karl Brand
2010-Jun-30 14:34 UTC
[R] Why the variation when creating .pdf file output for my plots?
Esteemed R Users, Would some one be patient enough to explain the variation i see when creating .pdf file output for my plots? FYI- my goal is produce the highest quality .pdf output from the R 'command line' as opposed to using the menu of the acitve graphics window. Im using 32bit WinXP. Session info at the bottom. I have Ghostscript v8.71 installed and in the Path such that C:\gswin32c.exe runs said program. All shared insights appreciated! Karl Method 1: In the R graphics device window, form the menu File>Save As>PDF -yields a .pdf file of 700Kb (in this plot example) Method 2: > dev2bitmap(file="expression.density.plotb.pdf", type = "pdfwrite", > method = "pdf") > dev.off() -yields a .pdf file of 300kb (same plot example) indistinguiashble (on the screen atleast) from method 1. Method 3: > pdf(file="my_plot.pdf", paper="a4") > dev.off() -yields a .pdf file of 1kb (same plot example) and returns the following error when attempting to open with Adobe acrobat: "There was an error opening this document. This file cannot be opened because it has no pages." SessionInfo() R version 2.10.1 (2009-12-14) i386-pc-mingw32 locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] grDevices datasets splines graphics stats tcltk utils methods [9] base other attached packages: [1] affy_1.24.2 Biobase_2.6.1 gdata_2.7.1 svSocket_0.9-48 TinnR_1.0.3 [6] R2HTML_1.59-1 Hmisc_3.7-0 survival_2.35-7 loaded via a namespace (and not attached): [1] affyio_1.14.0 cluster_1.12.1 grid_2.10.1 [4] gtools_2.6.1 lattice_0.17-26 preprocessCore_1.8.0 [7] svMisc_0.9-56 tools_2.10.1 -- Karl Brand <k.brand at erasmusmc.nl> Department of Genetics Erasmus MC Dr Molewaterplein 50 3015 GE Rotterdam P +31 (0)10 704 3409 | F +31 (0)10 704 4743 | M +31 (0)642 777 268
Erik Iverson
2010-Jun-30 14:58 UTC
[R] Why the variation when creating .pdf file output for my plots?
> > Method 3: > > pdf(file="my_plot.pdf", paper="a4") > > dev.off()The `pdf` function opens a *new* graphics device, you then send output to the device before calling dev.off(), e.g., pdf(file = my_plot.pdf") plot(1:10, 1:10) dev.off()> > -yields a .pdf file of 1kb (same plot example) and returns the following > error when attempting to open with Adobe acrobat: > > "There was an error opening this document. This file cannot be opened > because it has no pages."