I have a three facet figure with geombars in each.
Each facet represents a variable that I've used in other graphs where ggplot2 assigns them fill colors by default.
The faceted plots are black by default. I can change the fill color for all three panels but haven't found how to change each panel's fill to a different color.
Here is arbitrary data and code to represent the basic idea:
df = data.frame(matrix(data=c(1,3,1,2,3,1,2,3,2,3,1,2,3,1,2,3,
1,3,2,1,2,2,2,3,3,3,1,1,1,3,3,2),
ncol=2,byrow=TRUE))
dimnames(df)[[2]] =c("x","y")
dodgebars <-
ggplot(data = df,aes(factor(y),fill=factor(x))) +
geom_bar(aes(group=factor(x)),
position="dodge")
facetedbars <-
ggplot(data = df, aes(factor(y))) +
geom_bar(aes(group=x)) +
facet_grid(~x)
How can the color of each facet be matched to it's fill cover in "dodgebars?"