[R] looping multipanel plots to different figures

2015-02-19 Thread efisio solazzo
Dear, cannot find a way to direct multipanel plots to different figures (files) while within a loop. Say, the loop creates two plots each step: one plot should go to figure 1 and the other to figure 2. Same for the next steps of the loop: the plots should go to figure 1 and figure 2 in a

Re: [R] looping multipanel plots to different figures

2015-02-19 Thread Jim Lemon
Hi efisio, I read this as wanting to start a new graphics device, then set some plot parameters, display two plots and then close the graphics device at each iteration of the loop. If so, plot_filenames-c(plot1.png,plot2.png,plot3.png) for(plotfn in plot_filenames) { png(plotfn)

Re: [R] looping multipanel plots to different figures

2015-02-19 Thread efisio solazzo
Thanks Jim, actually I need to keep open two devices at the same time, and within the loop access either of them in alternation. In MatLab there is the command Figure(#) which keeps track of the open devices and direct the output of the plot to whichever of them. For example:

Re: [R] looping multipanel plots to different figures

2015-02-19 Thread Jim Lemon
Hi efisio, Okay, you can switch devices using the dev.* functions in the grDevices package. If you only have two devices open at one time, this is not too difficult: #open both devices png(...) par(mfrow=c(1,2)) png(...) par(mfrow=c(1,2)) hist(...) dev.set(dev.next()) hist(...)