Reputation: 23995
I can create a faceted plot like so, with 3 plots stacked vertically:
ggplot(iris, aes(Petal.Length)) + stat_bin() + facet_grid(Species ~ .)
Is it possible to move the labels to the top of each graph, like they would be if I'd done horizontal stacking with facet_grid(. ~ Species)
?
The reason I want this is that my plots are long time series plots, so I want the full width for each one, but the labels (which essentially function as titles to explain the facets) for each plot are too long to fit in the small label area at the right of the plot.
Upvotes: 13
Views: 5877
Reputation: 179468
Yes. Use facet_wrap
instead of facet_grid
and be sure to also specify the argument ncol=1
:
ggplot(iris, aes(Petal.Length)) + stat_bin() + facet_wrap(~Species, ncol=1)
Upvotes: 14
Reputation: 173627
Try this:
ggplot(iris, aes(Petal.Length)) + stat_bin() + facet_wrap(~Species,nrow = 3)
Upvotes: 4