In R basic plot, the outer margins can be controlled through oma()
, and I wonder if there is a similar function in ggplot2
to do this. As the following figure shows, the is almost no space between and figure and the edge of the page. Thanks a lot.
Please note that I am not asking about set margins between each sub-plot (this can be done by plot.margin=
in ggplot2). What I am asking is how to set the outer margin for the whole figure (something like oma
in R basic plot). Thanks.
require(cowplot)
require(ggplot2)
x=1:50
y=x^2
z=rep(c("p","sp","n","sn","nt"),each=10)
mydata= data.frame(x,y,z)
plot1=ggplot(mydata,aes(x=x,y=y,group=z))+geom_point(aes(shape=z,color=z),size=1)+scale_shape_manual(values=c(19,1,19,17,17))+scale_color_manual(values=c("blue","black","red","blue","red"))
plot2=ggplot(mydata,aes(x=x,y=y,group=z))+geom_point(aes(shape=z,color=z),size=3)+scale_shape_manual(values=c(19,1,19,17,17))+scale_color_manual(values=c("blue","black","red","blue","red"))
plot3=ggplot(mydata,aes(x=x,y=y,group=z))+geom_point(aes(shape=z,color=z),size=5)+scale_shape_manual(values=c(19,1,19,17,17))+scale_color_manual(values=c("blue","black","red","blue","red"))
plot4=ggplot(mydata,aes(x=x,y=y,group=z))+geom_point(aes(shape=z,color=z),size=7)+scale_shape_manual(values=c(19,1,19,17,17))+scale_color_manual(values=c("blue","black","red","blue","red"))
plot_grid(plot1, plot2, plot1,plot1, align='h', labels=c('a', 'b',"c","d"))