[Update]:I found a great graph design for bar charts that I'd like to recreate in R, but I'm having difficulty with some of the major elements (it's from 538). Below is a picture of the graph and my progress so far.
Here's the graph I'm trying to recreate
Here's my code:
convicted <- c(0.68, 0.33)
incarcertated <- c(0.48, 0.12)
group <- c("GENERAL POPULATION", "LAW ENFORCEMENT")
df <- data.frame(convicted, incarcertated, group)
mdf <- melt(df)
ggplot(mdf) +
geom_bar(aes(x=variable, y=1), stat="identity", alpha=.1, position=position_dodge(1)) +
geom_bar(aes(x=variable, y=value, fill=group), stat="identity", position=position_dodge(1)) +
scale_fill_manual(values=c("#058cd3", "#ff2700"))
Here's what I'm not sure how to do
- Get the "group" label to sit on top of each group and separate them *(key design element)
- Create a title and gray subheader
- get the color gray bars to separate the same distance as the colored bars
- get the value labels to dodge with bar charts
I will add that in my ideal recreation, the colors would be separated (so incarcerated with be the same color in both groups).
Would love help re-creating this chat as precisely as possible. I'm pretty sure this was created in R, so I'm know it can be done. Thanks for the help!
[Update]: thanks to the help of hfty I'm getting very close, but i get a weird border effect, which I couldn't upload to the comment sections, so i've done it here. What's going on with this?