ggplot: How to increase spacing between faceted plots?
I have several faceted histograms (obtained with the command below) which are nicely plotted one u开发者_StackOverflownder the other. I would like to increase the spacing between them, however, they are tight.
I looked at the doc but didn't find a parameter for this.
qplot (Happiness.Level, Number.of.Answers, data=mydata, geom="histogram") + facet_grid (Location ~ .)
Use the theme function:
library(grid)
p + theme(panel.spacing = unit(2, "lines"))
See also here: Slicing plots generated by ggplot2
Just to add to @rcs response:
# Change spacing between facets on both axis
p + theme(panel.spacing = unit(2, "lines"))
# Change horizontal spacing between facets
p + theme(panel.spacing.x = unit(2, "lines"))
# Change vertical spacing between facets
p + theme(panel.spacing.y = unit(2, "lines"))
精彩评论