library(ggplot2) GROUP <- c("Strongly disagree\n2016", "Strongly disagree\n2020", "Strongly agree\n2016","Strongly agree\n2020") PE <- c(5.7, 61.8, 21.2, 2.3) CILO <- c(4.4, 59.4, 17.9, 1.6) CIHI <- c(7.4, 64.0, 24.9, 3.3) COLORS <- c("slategray4", "slategray4", "slategray1", "slategray1") DATA <- data.frame(GROUP, PE, CILO, CIHI, COLORS) plot.1 <- ggplot(data=DATA, aes(x=GROUP, y=PE, fill=factor(GROUP, level=GROUP))) + geom_bar(stat="identity", position="dodge", color="black", size=1.1, width=0.85) + geom_errorbar(aes(ymin=CILO, ymax=CIHI), width=0.15, position=position_dodge(0.85)) + labs(title="Response of 'Not at all confident' to a question\n about how confident the respondent is that\nvotes in the ___ election were accurately counted", x="Response to 'Over the past few years, Blacks have gotten less than they deserve'") + scale_fill_manual(values=COLORS) + scale_x_discrete(limits=(GROUP), labels=GROUP) + scale_y_continuous(limits=c(0,100), breaks=seq(0,100,20), labels=seq(0,100,20), expand=c(0,0), name="%", sec.axis=dup_axis()) + labs(caption="Data source: 2016, Sept 2020, and Nov 2020 waves of the Democracy Fund Voter Study Group VOTER\nSurvey. Error bars are 83.4% confidence intervals. See: https://www.ljzigerell.com/?p=9046.\nItem in 2016: 'How confident are you that the votes in the 2016 election across the country were\naccurately counted?'. Item in 2020: 'How confident are you that votes across the United States were counted\nas voters intended in the elections this November?'") plot.1 theme.z <- theme( plot.background = element_rect(fill="white"), plot.margin = unit(c(0.5,0.5,0.5,0.5),"cm"), plot.title = element_text(face="bold", margin=margin(t=0, b=12), size=16, hjust=0.5), plot.subtitle = element_text(size=12, hjust=0.5, margin=margin(b=7)), plot.caption = element_text(size= 9, hjust=0.0, margin=margin(t=7)), strip.background = element_rect(color="black", fill="black"), strip.text.x = element_text(size=14, color="white", face="bold"), panel.background = element_rect(fill="gray90", color="black", size=0.5, linetype="solid"), panel.border = element_rect(fill=NA, color="black", linetype="solid", size=1.5), panel.grid.major.x = element_blank(), panel.grid.major.y = element_blank(), panel.grid.minor.x = element_blank(), panel.grid.minor.y = element_blank(), panel.spacing.x = unit(1, "lines"), panel.spacing.y = unit(1, "lines"), axis.text.x = element_text(size=12, color="black", margin=margin(t=7, b=5)), axis.text.y = element_text(size=12, color="black", margin=margin(l=7, r=7)), axis.text.y.right = element_text(size=12, color="black", margin=margin(l=7, r=7)), axis.ticks.y = element_blank(), axis.ticks.x = element_blank(), axis.title.y = element_blank(), axis.title.x = element_text(size=12, color="black", margin=margin(t=7, b=5)), legend.position = "none") plot.1 + theme.z ggsave(file="D:Rhodes et al 2022 VOTER.svg", width=7, height=6)