Skip to content

how to control to save plots to which dev

7 messages · Jeff Newmiller, David Winsemius, Brian Ripley +2 more

#
Hi,

I have a for loop to make 2 types of plots and I'd like to save one
type of plots to a pdf file and the other to another pdf file. How can
I control which plot will be saved to which pdf? Thanks
#
On Aug 1, 2011, at 11:14 PM, zhenjiang xu wrote:

            
Why not give them file names that identify the type?
#
On Tue, 2 Aug 2011, David Winsemius wrote:

            
I think he wants

pdf("a.pdf")
pdf("b.pdf")
for(i in 1:n) {
plot something on a.pdf
plot something on b.pdf
}

This is done using dev.prev/dev.next/dev.set: see their help for 
details.

  
    
3 days later
#
Thanks, Prof Ripley. I was using dev.next(), dev.prev(),, but I am
wondering, instead of switching the current dev, is there a way to
more directly print plot A into file connection A, plot B into file
connection B...? Because if coding with more then two dev
simultaniously, one could easily get confused which dev is the current
one.
On Tue, Aug 2, 2011 at 1:28 AM, Prof Brian Ripley <ripley at stats.ox.ac.uk> wrote:

  
    
#
On 05/08/2011 11:49 AM, zhenjiang xu wrote:
dev.set() will do exactly that (and Prof. Ripley did point you to it).

Duncan Murdoch
#
Yes, but I thought the parameter to dev.set() should only be the value
returned by dev.next()/dev.prev(). So I read the help page again. It's a
little embarrassing - I missed the sentence "Devices are associated
with ... a number in the range 1 to 63". I should have read the help
page more carefully. Thanks.

On Fri, Aug 5, 2011 at 12:02 PM, Duncan Murdoch
<murdoch.duncan at gmail.com> wrote: