Reputation: 434
Here is a plot that is very similar to one that I made for a stakeholder:
diamonds %>%
group_by(cut, color) %>%
summarise(av_price = mean(price)) %>%
ggplot(aes(color)) +
geom_bar(aes(weight = av_price)) +
facet_wrap(cut ~ .)
I've been asked to remove the facets and instead display each cut on the same chart but with some space between each (and perhaps each with their own color for readability?)
I do not know how to get this done. Tried:
diamonds %>%
group_by(cut, color) %>%
summarise(av_price = mean(price)) %>%
ggplot(aes(color, cut)) +
geom_bar(aes(weight = av_price))
Error: stat_count() can only have an x or y aesthetic.
How can I display each cut on a single chart as opposed to facets?
Upvotes: 0
Views: 116
Reputation: 123
How about this solution:
diamonds %>%
group_by(cut, color) %>%
summarise(av_price = mean(price)) %>%
ggplot(aes(color, av_price, fill=cut)) +
geom_col(position="dodge") +
facet_wrap(~cut, nrow=1) +
theme(strip.text.x = element_blank())
Upvotes: 1