I have four ggplot2 objects to be arranged in a 2-by-2 layout figure, and I refer to this function here: the multiplot
function works well if each of my four plots is provided. For example:
multiplot(p1, p2, p3, p4, cols=2, layout=matrix(seq(1,4), nr=2, byrow=TRUE))
However, in each of the plot, I suppress the x- and y-axis labels, because they are identical and I hope to put a global x-axis label and a global y-axis label on the 2-by-2 big panel. Is there a way to modify the multiplot
function to achieve this?
There is a related post here, but it seems to be outdated. It also provides a reproducible example. Thank you!
Update
Thanks Scott for the solution. One more question while I add the axis labels: how can I control the margin of the entire figure? I tried to use plot.margin
in theme
, but the problem of not showing the complete labels still remain. Please see the attached screenshot below: