Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create plots in multiple windows and keep them separate in R

Tags:

r

graphics

I'm sure this is an easy problem, but my google / help foo has failed me, so it's up to you.

I have an R script that generates several plots, and I want to view all the plots on screen at once (in separate windows), but I can't work out how to open multiple graphics windows. I'm using ggplot2, but I feel this is a more basic problem, so I'm just using base grapics for this simple example

x<-c(1:10) y<-sin(x) z<-cos(x) dev.new() plot(y=y,x=x) dev.off() dev.new() plot(x=x,y=z)  

But this doesn't work. I'm on Windows if this matters (Windows + Eclipse + StatEt)

like image 589
PaulHurleyuk Avatar asked May 14 '10 18:05

PaulHurleyuk


People also ask

How would you make multiple plots onto a single page in R?

To arrange multiple ggplot2 graphs on the same page, the standard R functions - par() and layout() - cannot be used. The basic solution is to use the gridExtra R package, which comes with the following functions: grid. arrange() and arrangeGrob() to arrange multiple ggplots on one page.

How do I save multiple plots in R?

To save multiple plots to the same page in the PDF file, we use the par() function to create a grid and then add plots to the grid. In this way, all the plots are saved on the same page of the pdf file. We use the mfrow argument to the par() function to create the desired grid.


1 Answers

This works fine if you remove the line with dev.off().

like image 59
Shane Avatar answered Sep 28 '22 04:09

Shane