Reputation: 109844
I have used a stacked bar chart (with coord_flip) to try to compare distributions (this is one a several techniques I'm playing with) for a control and treatment group for pre and post test. Here is the plot:
and here is the code (Sorry it's not reproducible with no data set. If this is a problem I'll make up a reproducible data set as I can't share the real data):
m4 <- ggplot(data=v, aes(x=trt, fill=value))
m5 <- m4 + geom_bar() + coord_flip() +
facet_grid(time~type) + scale_fill_grey()
How can I change the y axis (which is actually on the bottom dues to coord_flip
) to percents so every bar is equal in length? So I want counts to become percents. I need some sort of transformation that I'm betting ggplot has or could easily be created and applied some how.
Upvotes: 2
Views: 558
Reputation: 173517
You probably just want position_fill, by setting,
+ geom_bar(position = "fill")
Upvotes: 2