Increasing area around plot area in ggplot2
ggplot2, plot, r
Solution
Margins around plot can be modified with `theme()`, `plot.margin =` and function `margin()` where you provide size of margins starting with top, then right, bottom and left, and units (default is "pt").
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 = margin(1,1,1.5,1.2, "cm"))
Problem
How can I increase the area around a plot area in ggplot 2 to give my axis titles some breathing room. I am aware of vjust and hjust (as below), however, I can't seem to create actual space around the plotting area to move my axes titles onto. ``` 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 ```