I have a dataframe:
df1 <- data.frame(place = c("a", "a", "b", "b", "c", "c", "d", "d", "e", "e", "f", "f", "g", "g",
"h", "h", "i", "i", "j", "j", "k", "k", "l", "l", "m", "m", "n",
"n", "o", "o", "p", "p", "q", "q"),
cost_other = c("cost_savings", "other_savings",
"cost_savings", "other_savings",
"cost_savings", "other_savings",
"cost_savings", "other_savings",
"cost_savings", "other_savings",
"cost_savings", "other_savings",
"cost_savings", "other_savings",
"cost_savings", "other_savings",
"cost_savings", "other_savings",
"cost_savings", "other_savings",
"cost_savings", "other_savings",
"cost_savings", "other_savings",
"cost_savings", "other_savings",
"cost_savings", "other_savings",
"cost_savings", "other_savings",
"cost_savings", "other_savings",
"cost_savings", "other_savings"),
values = c(1.8,0.55, 0.836, 1.06, 1.096, 1.83875908682016,
0.966, 1.34497094648805, 1.62275, 0.600277163210231, 0.873875,
0.875130680022367, 1.487, 0.283241350805961, 1.0776, 0.849116238360361,
1.221, 1.45510685371131, 0.961882352941176, 1.30607084680655,
1.027, 1.52026452067783, 0.807666666666667, 1.22377282341786,
0.788384615384615, 0.984172521942087, 0.975, 1.94002090880358,
1.00333333333333, 1.18402178405582, 0.8956, 1.16165422673896,
0.95975, 0.825533052928448))
I want to create a facet-wrap-based geom_bar chart using these data, such that every faceted space shows all the bar charts in grey color. Then, I need the specific bars for specific grid to be in any color.
I tried doing it, but got something like this:
I used this to get my result:
ggplot(data=df,aes(x=place,
y=values))+
geom_bar(aes(fill=cost_other),
stat = "identity",
position = "dodge") +
facet_wrap(~place) +
theme_calc()+
theme(legend.position = "none",
axis.text.x=element_blank())
I am getting the specific bars in color, but then all the other spaces are empty. I want other bars for all variables as well, specifically in grey color.