wishihadabettername wishihadabettername - 1 year ago 179
R Question

ggplot: How to increase spacing between faceted plots?

I have several faceted histograms (obtained with the command below) which are nicely plotted one under 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.

Thanks in advance.

qplot (Happiness.Level, Number.of.Answers, data=mydata, geom="histogram") + facet_grid (Location ~ .)

rcs rcs
Answer Source

Use the theme function:

p + theme(panel.margin = unit(2, "lines"))

Update: panel.margin is deprecated, use panel.spacing instead:

p + theme(panel.spacing = unit(2, "lines"))

(For old versions of ggplot prior to 0.9.2, use opts instead of theme.)

See also here: Slicing plots generated by ggplot2

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download