Trying to keep filled bars in a grunge plot

Not sure what I'm doing wrong here. I have this plot:

ggplot(data.PE5, aes(ybands,fill=factor(decide))) + geom_bar(position="dodge") 

which produces: colored.png

Then I want to focus the factor by creating two folded graphs with dodging, color bars

 ggplot(data.PE5, aes(ybands,fill=factor(decide))) + geom_bar(position="dodge") + facet_grid(~group_label) 

However, I am losing the factor coloring that I want to keep:

non_colored.png

+4
source share
1 answer

If you move fill to geom_bar , it should work. IN:

 ggplot(data.PE5, aes(ybands)) + geom_bar(aes(fill=factor(decide)),position="dodge") + facet_grid(~group_label) 

The reason is that ggplot2 builds graphs like a grammar (I think).

+2
source

Source: https://habr.com/ru/post/1307583/


All Articles