如何增加ggplot 2中绘图区域周围的区域,使我的轴标题有一些喘息空间.我知道vjust和hjust(如下所示),然而,我似乎无法在绘图区域周围创建实际空间来移动我的轴标题.
p <- ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point()
p
p<- p + theme(axis.title.x = element_text(family="Times",size=20,face="bold",colour = "Black",vjust=-1,hjust=0.5)) 
p

Did*_*rts 51
可以使用theme()以及plot.margin=从顶部,右侧,底部和左侧开始提供边距大小的位置修改绘图周围的边距.库grid附加到使用功能unit().
library(grid)
ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point() + 
  theme(axis.title.x = element_text(family="Times",size=20,
                face="bold",colour = "Black",vjust=-1,hjust=0.5))+
  theme(plot.margin=unit(c(1,1,1.5,1.2),"cm"))