[R] Save multiple plots in a single pdf file when the plots are generated by a single plot command

Jim Holtman jholtman at gmail.com
Sat Jun 16 04:33:06 CEST 2012


the other command to use is

graphics.off()

Sent from my iPad

On Jun 15, 2012, at 19:14, Debs Majumdar <debs_stata at yahoo.com> wrote:

> I thought that might be the case and did a couple of dev.off() even though I started a new R session. Each time I try to use the plot, it comes up with "pdf 2".
> 
> 
> 
> ----- Original Message -----
> From: R. Michael Weylandt <michael.weylandt at gmail.com>
> To: Debs Majumdar <debs_stata at yahoo.com>
> Cc: "r-help at r-project.org" <r-help at r-project.org>
> Sent: Friday, June 15, 2012 4:10 PM
> Subject: Re: [R] Save multiple plots in a single pdf file when the plots are generated by a single plot command
> 
> It looks like you have one too many pdf objects open. The "pdf 2" that
> is printed indicates control was returned to another pdf device. Keep
> doing dev.off() until you get the message "null device 1" and then try
> it once again.
> 
> Best,
> Michael
> 
> On Fri, Jun 15, 2012 at 6:06 PM, Debs Majumdar <debs_stata at yahoo.com> wrote:
>> I am using R 2.15.0 on Windows 7.
>> 
>> It shows the plots on the screen. I can page-up and page-down to look at the different plots. It's when I want to save the plot, I get a blank pdf file (0 kb).
>> 
>> #############
>>> pdf("education.pdf")
>>> plot(ed_dif, labels = c("White", "African American"))
>>> dev.off()
>> pdf
>>   2
>>> 
>> ############
>> 
>> 
>> 
>> 
>> ----- Original Message -----
>> From: R. Michael Weylandt <michael.weylandt at gmail.com>
>> To: Debs Majumdar <debs_stata at yahoo.com>
>> Cc: "r-help at r-project.org" <r-help at r-project.org>
>> Sent: Friday, June 15, 2012 3:48 PM
>> Subject: Re: [R] Save multiple plots in a single pdf file when the plots are generated by a single plot command
>> 
>> On Fri, Jun 15, 2012 at 4:39 PM, Debs Majumdar <debs_stata at yahoo.com> wrote:
>>> Hi,
>>> 
>>> I am trying to save multiple plots in a single pdf file when  the plots are generated by a single plot command. I am using the "lordif" package which generates multiple plots with one command.
>>> 
>>> pdf("education.pdf")
>>> plot.lordif(ed_dif, labels = c("White", "African American"))
>>> dev.off()
>>> 
>>> And this is not working at all. Thanks for your help.
>> 
>> What do you mean by this? Is it the file not being created? Or its
>> blank? Or you get the wrong output? Does it work to print to a screen
>> device but not a pdf? Etc.
>> 
>> Running the example in ?lordif, this works for me:
>> 
>> pdf("test.pdf")
>> plot(age.DIF)
>> dev.off()
>> 
>> What OS are you on and what version of R?
>> 
>> In short, happy to help, but we need (much) more information.
>> 
>> Michael
>> 
>>> 
>>> Debs
>>> 
>>> ______________________________________________
>>> R-help at r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>> 
> 
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list