0 votes
1 view
in R Programming by (6.5k points)

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 ~ .)

1 Answer

0 votes
by (25.3k points)

To increase the spacing between faceted plots, you can use the panel.spacing argument in the theme function as follows:

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

For example:

library("ggplot2")

library(grid)

ggplot(mtcars, aes(x = cyl, fill = gear)) +

  geom_bar()+

  theme_bw()+

  facet_grid(.~am)+

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

Output:
image

Related questions

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...