John
John

Reputation: 1947

Easiest way how to plot plenty side by side graphs using ggplot

Let's say we want to plot 12 graphs side-by-side using ggplot. For instance

qplot(x,3*x+eps) #I want to have 12 graphs of this 
plot_grid()      #And now I can insert 12 times qplot above into plot_grid to get my result. 

My question is : is there any way how can I plot it without putting qplot to plot_grid 12 times ?

Thanks in advance!

Upvotes: 0

Views: 48

Answers (1)

Ronak Shah
Ronak Shah

Reputation: 389215

Use replicate to repeat the plots and do.call to plot them using plot_grid :

do.call(cowplot::plot_grid, replicate(12, qplot(x,3*x+eps), simplify = FALSE))

Upvotes: 1

Related Questions