Reputation: 804
I'm producing a facet diagram with ggplot2. I would like to change the margin. I have found that the panel.margin argument to theme() can be used to change margin size.
library(grid)
p <- ggplot(mtcars, aes(mpg, wt)) + geom_point()
p + facet_grid(vs ~ am)
p <- p + facet_grid(vs ~ am)
p <- p + theme(panel.margin = unit(3, "lines"))
p
I would like to change independently the margin size in x (horizontal) or y (vertical) directions. Is there a solution to do that ?
Thank you for helping
Upvotes: 0
Views: 298
Reputation: 7469
The parameter you are looking for has been renamed to panel.spacing
:
p <- ggplot(mtcars, aes(mpg, wt)) + geom_point()
p + facet_grid(vs ~ am)
p <- p + facet_grid(vs ~ am)
p <- p + theme(panel.spacing.x = unit(1, "lines"),
panel.spacing.y = unit(3, "lines"))
p
Upvotes: 1