Question

I have four plots that I would like to plot on the same figure using:

library(gridExtra)
grid.arrange(plot1,plot2,plot3,plot4)

By default grid.arrange will plot the first two on the top and the other two in the bottom. Is there a way to plot all four plots next to each other for example?

Était-ce utile?

La solution

You can use the argument nrow = 1 if you want all plots in one row

grid.arrange(plot1, plot2, plot3, plot4, nrow = 1)

You can also use the argument ncol = 1 if you want all plots in one column

grid.arrange(plot1, plot2, plot3, plot4, ncol = 1)

Autres conseils

using cowplot can give same result. Cowplot has plot grid that allows to arrange the plots in order as your wish.

plot_grid(p,q,align=c('h','v'),ncol=,labels=)

Use align to arrange the plot vertically(v) or horizontally(h), and labels to individually label each plot.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top