library(ggplot2) df <- read.csv('seats-votes.csv') df$year <- as.factor(df$year) # scatterplot w/o jitter png("f1.png",width=672,height=671) qplot(year,voteshare,data=df,geom="point",alpha=I(.15),xlab="Year", ylab="Democratic Vote Share (%)",main="Democratic Vote Share US House 2002-2008")+ geom_hline(yintercept=50,colour="gray50") dev.off() # scatterplot w/ jitter png("f2.png",width=672,height=671) qplot(year,voteshare,data=df,geom="jitter",alpha=I(.35),xlab="Year", ylab="Democratic Vote Share (%)",main="Democratic Vote Share US House 2002-2008") + geom_hline(yintercept=50,colour="gray50") dev.off() # simple histogram png("f3.png",width=672,height=671) qplot(voteshare,data=df,geom="histogram",binwidth=2,xlab="Democratic Vote Share (%)", ylab="Count",main="Democratic Vote Share US House 2002-2008") + facet_wrap(~year,nrow=2) + geom_vline(xintercept=50,colour="gray50") dev.off() # density plot png("f4.png",width=672,height=671) qplot(voteshare,data=df, geom=c("density", "rug"),xlab="Democratic Vote Share (%)", ylab="Density",main="Democratic Vote Share US House 2002-2008") + facet_wrap(~year,nrow=2)+ geom_vline(xintercept=50,colour="gray50") dev.off() # min/max boxplot png("f5.png",width=672,height=671) qplot(year,voteshare,data=df,geom="boxplot",xlab="Year", ylab="Democratic Vote Share (%)",main="Democratic Vote Share US House 2002-2008")+ geom_hline(yintercept=50,colour="gray50") dev.off()