as a new ggplot2 user, I am a bit lost with the amount of possibilities, and struggle to find on the net a simple answer to what I consider a simple problem.
I would like to display multiple plots from ggplot2 on a same sheet, BUT knowing that these plots come from a for loop.
Following example does not compile, it is only to illustrate :
for(i in c(1:n)){
for(j in c(1:m)){
.......... # some data production
p <- ggplot(df.all) + geom_bar(aes_string(x=class.names[i],fill=var.names[j])
}}
Here, p is overwritten, but I would like to have instead a matrix or a list in which I can put all the p as they are produced, then a simple function like
display_in_a_grid(list_of_ggplot_plots)
But as far as I tried, I was not able to make a list of matrix of plot, neither to find a function that takes only one argument for input.
About things I have had a look at :
"arrangeGrob" from package gridExtra doesn't work because it requires an explicit name for each plot (e.g.: p1,p2,p3,...) like in http://code.google.com/p/gridextra/wiki/arrangeGrob
"facet" method of ggplot2 is not adapted to the organization of my data set (or the contrary :p )
Would you have a simple way to manage this ?
Thank you,
Fran?ois
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…