Reputation: 23
I am new to R and my professor asked me to position the histograms vertically. I am required to use only ggplot2
. Here is my code:
(ggplot(data=shippingData, aes(Days)) +
geom_histogram(binwidth=1,col="gray",
fill="steelblue",
alpha = 1) +
labs(title="Delivery Times(in Days) by Center") +
labs(x="Days)", y="Count") + facet_grid(facets=. ~ Center))
Output is positioned as horizontally like this :
But it is supposed to look like this:
Upvotes: 2
Views: 579
Reputation: 226637
Try facet_grid(facets=Center ~ .)
or facet_wrap(~Center, ncol=1)
Upvotes: 2
Reputation: 160
You could also try facet_grid(rows = vars(Center)
.
If you want to use facet_wrap
to get the labels on top, try this:
facet_wrap(~Center, nrow = 3)
.
Upvotes: 2