質問

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?

役に立ちましたか?

解決

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)

他のヒント

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top