# pdf("E:R-Burge3.pdf", width=11, height=3) # win.metafile("E:R-Burge3.wmf", width=11, height=3) # svg(filename="E:R-Burge3.svg", width=11, height=3, pointsize=20) # install.packages("ggplot2", dependencies=TRUE) library(ggplot2) DATA <- read.csv(file.choose(), header=TRUE) DATA$OUTCOME <- factor(DATA$OUTCOME, levels=rev(c("Willingness to vote for", "Likelihood of receiving the Black vote", "Ability to represent interests"))) DATA$ITEM <- factor(DATA$ITEM2, levels=c("Dark Julie vs. Light Julie", "Dark James vs. Light James", "Dark Julie vs. Dark James")) plot <- ggplot(DATA, aes(COEFF, OUTCOME)) + geom_rect(data=NULL,aes(xmin=-Inf, xmax=0, ymin=-Inf, ymax=Inf), fill="lightsteelblue3") + geom_point(size=2.5) + geom_errorbarh(aes(xmin=LO95CI, xmax=HI95CI), height=0, size=0.75) + facet_wrap(~ITEM, ncol=3, dir="v") + geom_vline(xintercept=0) + scale_x_continuous(name="Difference on a 100-point scale", breaks=seq(-15,15,5), labels=scales::number_format(accuracy=1), expand=c(0,0), limits=c(-15,15)) + labs(caption="Data source: Burge et al. 2020 JOP.\nError bars are 95% confidence intervals.") + theme( plot.background=element_rect(fill="white"), plot.title=element_text(face="bold", margin=margin(t=0, b=13), size=13, hjust=0.5), plot.subtitle=element_text(hjust=0.5), plot.caption=element_text(hjust=1), plot.margin=unit(c(0.5,0.5,0.5,0.5),"cm"), strip.background=element_rect(color="black", fill="black"), strip.text.x=element_text(color="white", face="bold", size=11), 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.background=element_rect(fill="lightsteelblue2", color="black", size=0.5, linetype="solid"), panel.border=element_rect(fill=NA, color="black", linetype="solid", size=1.5), panel.spacing.x=unit(1, "lines"), panel.spacing.y=unit(1, "lines"), axis.title.y=element_blank(), axis.title.x=element_text(size=9, color="black"), axis.ticks.y=element_blank(), axis.ticks.x=element_blank(), axis.text.x=element_text(color="black"), axis.text.y=element_text(color="black")) plot # dev.off()