Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Saving multiple boxplots

Tags:

r

save

boxplot

I've made a loop to create multiple boxplots. The thing is, I want to save all the boxplots without overwriting each other. Any suggestions?

This is my current code:

boxplot <- list()
for (x in 1:nrow(checkresults)){
    boxplots <- boxplot(PIM[,x], MYC [,x], OBX[,x], WDR[,x], EV[,x], 
                        main=colnames(PIM)[x], 
                        xlab="PIM, MYC, OBX, WDR, EV")
}
like image 425
lisanne Avatar asked Mar 14 '11 13:03

lisanne


People also ask

How do you do multiple box plots?

This can be accomplished by using boxplot() function, and we can also pass in a list, data frame or multiple vectors to it. For this purpose, we need to put name of data into boxplot() function as input. Parameters: x: This parameter sets as a vector or a formula.


1 Answers

Do you want to save them in some files, or save them to be able to look at them in different windows ?

If it is the first case, you can use a png, pdf or whatever function call inside your for loop :

R> for (i in 1:5) { 
R>    png(file=paste("plot",i,".png",sep=""))
R>    plot(rnorm(10))
R>    dev.off() 
R> }

If you want to display them in separate windows, just use dev.new :

R> for (i in 1:5) { 
R>    dev.new()
R>    plot(rnorm(10)); 
R> }
like image 136
juba Avatar answered Oct 14 '22 19:10

juba