#Initialization has to be processed once in order for any of these graphs to be #created. #Libraries libs <- c("ggplot2", "reshape2", "plyr", "scales", "grid", "RColorBrewer", "foreign", "GGally", "car") lapply(libs, require, character.only=TRUE) #Set Path of Replication Data Folder inpath <- "[file path]" #Set Path of Replication Output Graph File outpath <- "[file path]" #Figure 3.1 Does not Contain Data (Theory Schema) #Figure 3.2 #Load Data BL <- read.dta(file=sprintf("%s%s", inpath, "BenoitLaver.dta")) #Subset Data BL.ltd <- data.frame(cbind(BL$taxspend, BL$social2, BL$immigration, BL$environment)) #New Column Names colnames(BL.ltd)[1] <- "Tax" colnames(BL.ltd)[2] <- "Moral" colnames(BL.ltd)[3] <- "Immig" colnames(BL.ltd)[4] <- "Enviro" labels <- c("Taxes vs Spending", "Social Morality", "Immigration", "Environmentalism") #Create Scatterplot Matrix #Histogram on diagonal panel.hist <- function(x, ...) { usr <- par("usr"); on.exit(par(usr)) par(usr = c(usr[1:2], 0, 1.5) ) h <- hist(x, plot = FALSE) breaks <- h$breaks; nB <- length(breaks) y <- h$counts; y <- y/max(y) rect(breaks[-nB], 0, breaks[-1], y, col = "white", ...) } #TIFF Format tiff(sprintf("%s%s", outpath, "ch3-f2-BLIssues.tif"), width=12, height=8, units='in', res=500) pairs(~Tax+Moral+Immig+Enviro, data=BL.ltd, labels=c("Taxes vs. Spending", "Social Morality", "Immigration", "Environment"), lower.panel=panel.smooth, upper.panel=panel.smooth, col.smooth="black", diag.panel=panel.hist, xlim=c(1,20), ylim=c(1,20)) dev.off() #PNG Format png(sprintf("%s%s", outpath, "ch3-f2-BLIssues.png"), width=6, height=4, units='in', res=100) pairs(~Tax+Moral+Immig+Enviro, data=BL.ltd, labels=c("Taxes vs. Spending", "Social Morality", "Immigration", "Environment"), lower.panel=panel.smooth, upper.panel=panel.smooth, col.smooth="black", diag.panel=panel.hist, xlim=c(1,20), ylim=c(1,20)) dev.off() rm(labels) #Figure 4.1 is a GEPHI Graphic #Figure 4.2 #Load Data CMRPNodesXYcoords <- read.dta(file=sprintf("%s%s", inpath, "CMRPNodesXYcoords.dta")) #Create Scatterplot Unrotated <- ggplot(CMRPNodesXYcoords, aes(x=xcoord_rotatedn46, y=ycoord_rotatedn46)) + #n46 Baseline (unrotated) geom_point(color="grey50", shape=0) + geom_abline(intercept=0, slope=0) + scale_y_continuous(limits=c(-8000,8000), breaks=c(-8000, -4000, 0, 4000, 8000)) + scale_x_continuous(limits=c(-8000,8000), breaks=c(-8000, -4000, 0, 4000, 8000)) + geom_segment(x=0, y=0, xend=6000, yend=6000) + geom_segment(x=0, y=0, xend=-6000, yend=-6000) + geom_segment(x=0, y=0, xend=6000, yend=-6000) + geom_segment(x=0, y=0, xend=-6000, yend=6000) + geom_segment(x=0, y=0, xend=2000, yend=4000) + geom_segment(x=0, y=0, xend=-2000, yend=4000) + geom_segment(x=0, y=0, xend=2000, yend=-4000) + geom_segment(x=0, y=0, xend=-2000, yend=-4000) + geom_segment(x=0, y=0, xend=4000, yend=2000) + geom_segment(x=0, y=0, xend=-4000, yend=2000) + geom_segment(x=0, y=0, xend=4000, yend=-2000) + geom_segment(x=0, y=0, xend=-4000, yend=-2000) + geom_segment(x=0, y=-7500, xend=0, yend=7500) + theme(panel.background=element_rect(fill="white")) + theme(axis.title.x = element_text(size=25, color="black")) + theme(axis.text.x = element_text(size=25, color="black")) + theme(axis.text.y = element_text(size=25, color="black")) + theme(axis.title.y = element_text(size=25, color="black")) + xlab("\nx-coordinate") + ylab("y-coordinate\n") + annotate("text", x=0, y=-8000, size=7, label="-90(degree)", parse=T, color="black") + annotate("text", x=0, y=8000, size=7, label="+90(degree)", parse=T, color="black") + annotate("text", x=-6500, y=6500, size=7, label="+45(degree)", parse=T, color="black") + annotate("text", x=-6500, y=-6500, size=7, label="-45(degree)", parse=T, color="black") + annotate("text", x=6500, y=6500, size=7, label="-45(degree)", parse=T, color="black") + annotate("text", x=6500, y=-6500, size=7, label="+45(degree)", parse=T, color="black") Unrotated #TIFF Format ggsave(file=sprintf("%s%s", outpath, "ch4-f2-CMRP_Rotations.tiff"), width=10, height=10, dpi=600) #PNG Format ggsave(file=sprintf("%s%s", outpath, "ch4-f2-CMRP_Rotations.png"), width=10, height=10, dpi=600) #Figure 4.3 #Load Data ExpertsLRCorr <- read.csv(file=sprintf("%s%s", inpath, "CMRPRotationsExpertsLRCorr.csv")) #NB: CMRPRotationsExpertsLRCorr.csv manually constructed from CMRPNodesXYcoords.dta #Create Line Graph Degrees.Plot <- ggplot(ExpertsLRCorr, aes(x=Angle, y=Correlation)) + geom_line() + theme(panel.background=element_rect(fill="white")) + theme(axis.title.x = element_text(size=25, color="black")) + theme(axis.text.x = element_text(size=25, color="black")) + theme(axis.text.y = element_text(size=25, color="black")) + theme(axis.title.y = element_text(size=25, color="black")) + xlab("\nRotation Angle\n(Degrees)")+ ylab("\nCorrelation (r) \n Xcoord ~ Expert Judgments\n") + scale_x_continuous(breaks = c(-90, -80, -70, -60, -50, -40, -30, -20, -10, 0, 10, 20, 30, 40, 50, 60, 70, 80, 90)) + scale_y_continuous(breaks = c(-.5, -.4, -.3, -.2, -.1, 0, .1, .2, .3, .4, .5, .6)) + geom_vline(xintercept=44, color="black") + annotate("text", x=65, y=.6, size=7, label="r = .53", color="black") Degrees.Plot #TIFF Format ggsave(file=sprintf("%s%s", outpath, "ch4-f3-CMRPRotationsExpertsLRCorr.tiff"), width=12, height=8, dpi=600) #PNG Format ggsave(file=sprintf("%s%s", outpath, "ch4-f3-CMRPRotationsExpertsLRCorr.png"), width=12, height=8, dpi=600) #Figure 4.4 is a GEPHI Graphic #Figure 4.5 #Load Data Issues <- read.csv(file=sprintf("%s%s", inpath, "CMRP_Issues_Map.csv")) #NB: CMRP_Issues_Map.csv manually constructed from CMRPNodesXYcoords.dta Issues$sig <- with(Issues, reorder(sig, abs(wgt_xcoord), mean)) # Eventually darkens sig. corrs #Create Text Graph Issue_Map <- ggplot(Issues, aes(x=wgt_xcoord, y=wgt_ycoord_adj, label=label, color=sig)) + geom_vline(xintercept=.0, color="grey") + geom_text(size=3, position="jitter") + scale_x_continuous(limits=c(-.33,.33), breaks=c(-.3, -.15, 0, .15, .3)) + scale_y_continuous(limits=c(-.2,.2), breaks=c(-.2, -.1, 0, .1, .2)) + scale_color_manual(values=c("grey75", "gray40", "black")) + theme(axis.text.x=element_text(size=15, color="black")) + theme(axis.title.x=element_text(size=15, color="black")) + theme(axis.text.y=element_text(size=15, color="black")) + theme(axis.title.y=element_text(size=15, color="black")) + theme(plot.title=element_text(size=20)) + theme(legend.text=element_text(size=10, color="black")) + theme(panel.background=element_rect(fill="white")) + xlab(expression(paste(Corr[tau],"(xcoord, category)"))) + ylab(expression(paste(Corr[tau],"(ycoord, category)"))) + annotate("text", x=-.31, y=0, size=7, label="Left", color="black") + annotate("text", x=.31, y=0, size=7, label="Right", color="black") + annotate("text", x=0, y=-.2, size=7, label="Center", color="black") + theme(legend.position="bottom", legend.title=element_blank()) Issue_Map #TIFF Format ggsave(file=sprintf("%s%s", outpath, "ch4-f5-IssuesMap.tiff"), width=12, height=8, dpi=600) #PNG Format ggsave(file=sprintf("%s%s", outpath, "ch4-f5-IssuesMap.png"), width=12, height=8, dpi=600) #Figure 5.1 #Load Data CSES_US2004 <- read.csv(file=sprintf("%s%s", inpath, "CSES_UnitedStates_2004.csv")) #Raw Data from CSES 2004 BL.US <- read.csv(file=sprintf("%s%s", inpath, "BL_US_Individual_Level.csv")) #Raw Data from Benoit and Laver (Individual-level expert placements) #Create Density Graph from the CSES Data DemRepLR.CSES <- ggplot(CSES_US2004, x=LRA2) + geom_density(aes(x=LRA2), color="grey80", fill="grey80", alpha=.5) + geom_density(aes(x=LRB2), color="grey20", fill="grey20", alpha=.5) + geom_vline(xintercept=4.07, color="grey80") + geom_vline(xintercept=6.70, color="grey80") + xlab("\n Left/Right Position\n(CSES)") + ylab(" ") + scale_y_continuous(labels=percent_format()) + scale_x_continuous(breaks=c(0,5, 10)) + theme(axis.text.y = element_text(size=25)) + theme(axis.text.x = element_text(size=25)) + theme(axis.title.y = element_text(size=25)) + theme(axis.title.x = element_text(size=25)) + theme(panel.background=element_rect(fill="white")) + labs(title="Election Study\n") + theme(plot.title=element_text(size=25)) + geom_segment(aes(x=4.17, y=.2, xend=6.6, yend=.2),color="gray50", alpha=.25, arrow=arrow(length=unit(.2, "cm"))) + geom_segment(aes(x=6.6, y=.2, xend=4.17, yend=.2),color="gray50", alpha=.25, arrow=arrow(length=unit(.2, "cm"))) + geom_text(x=5.385, y=.192, label="2.6", color="gray50", size=8) + geom_text(x=3.8, y=.2, label="bar(x)", parse=T, color="grey20", size=8) + geom_text(x=6.97, y=.2, label="bar(x)", parse=T, color="grey20", size=8) + geom_text(x=2, y=.2, label="Democrat", parse=T, color="grey20", size=8) + geom_text(x=8.5, y=.2, label="Republican", parse=T, color="grey20", size=8) DemRepLR.CSES #TIFF Format ggsave(file=sprintf("%s%s", outpath, "ch5-f1a-CSES_Density_US_DemRepLR.tiff"), width=12, height=8, dpi=600) #PNG Format ggsave(file=sprintf("%s%s", outpath, "ch5-f1a-CSES_Density_US_DemRepLR.png"), width=12, height=8, dpi=600) #Create Density Graph from Benoit and Laver's Data DemRepLR.BL <- ggplot(BL.US, x=republican) + geom_density(aes(x=republican), color="grey80", fill="grey80", alpha=.5) + geom_density(aes(x=democrat), color="grey20", fill="grey20", alpha=.5) + geom_vline(xintercept=7.1, color="grey80") + geom_vline(xintercept=16.6, color="grey20") + ylab(" ") + xlab("\n Left/Right Position\n(Benoit and Laver)") + xlim(1,20) + scale_x_continuous(breaks=c(1,10.5, 20)) + scale_y_continuous(labels=percent_format()) + theme(axis.text.y = element_text(size=25)) + theme(axis.text.x = element_text(size=25)) + theme(axis.title.y = element_text(size=25)) + theme(axis.title.x = element_text(size=25)) + theme(panel.background=element_rect(fill="white"))+ labs(title="Expert Survey\n") + theme(plot.title=element_text(size=25)) + geom_segment(aes(x=7.3, y=.2, xend=16.4, yend=.2),color="gray50", alpha=.25, arrow=arrow(length=unit(.2, "cm"))) + geom_segment(aes(x=16.4, y=.2, xend=7.3, yend=.2),color="gray50", alpha=.25, arrow=arrow(length=unit(.2, "cm"))) + geom_text(x=11.85, y=.192, label="9.5", color="gray50", size=8) DemRepLR.BL #TIFF Format ggsave(file=sprintf("%s%s", outpath, "ch5-f1b-BL_Density_US_DemRepLR.tiff"), width=12, height=8, dpi=600) #PNG Format ggsave(file=sprintf("%s%s", outpath, "ch5-f1b-BL_Density_US_DemRepLR.png"), width=12, height=8, dpi=600) ##Figure 5.2 #Load Data CMRP <- read.dta(file=sprintf("%s%s", inpath, "CMRP_Original_withXYcoords.dta")) #Reorder Data for Bar Graph Shading CMRP$partyfam <- reorder(CMRP$partyfam, CMRP$Tau_Vanilla_rel_Legacy, mean, order=TRUE) Histogram.fig <- ggplot(CMRP, aes(x=Tau_Vanilla_rel_Legacy, fill=partyfam)) + geom_bar(binwidth=.25, position="stack") + ylab("Count\n") + xlab("\nLeft-Right Position") + guides(fill=guide_legend(title="Party Family")) + scale_x_continuous(limits=c(-15,15), breaks=c(-15, -10, -5, 0, 5, 10, 15), labels=c("Left", "-10", "-5", "0", "5", "10", "Right")) + theme(axis.text.x=element_text(size=15)) + theme(axis.title.x=element_text(size=15)) + theme(axis.text.y=element_text(size=15)) + theme(axis.title.y=element_text(size=15)) + theme(plot.title=element_text(size=20)) + theme(legend.text=element_text(size=15)) + theme(legend.title=element_text(size=15)) + scale_fill_manual(values=c("grey90", "grey70", "grey60", "grey50", "grey40", "grey30", "grey20" , "grey10", "black")) + theme(panel.background=element_rect(fill="white")) Histogram.fig #TIFF Format ggsave(file=sprintf("%s%s", outpath, "ch5-f2-CMRP_Histogram_VanillaTau.tiff"), width=12, height=8, dpi=600) #PNG Format ggsave(file=sprintf("%s%s", outpath, "ch5-f2-CMRP_Histogram_VanillaTau.png"), width=12, height=8, dpi=600) ##Figure 5.3 #Load Data CMRP <- read.dta(file=sprintf("%s%s", inpath, "CMRP_Original_withXYcoords.dta")) #Reorder Data for Point Shading CMRP$partyfam <- reorder(CMRP$partyfam, CMRP$Tau_Vanilla_rel_Legacy, mean, order=TRUE) TaubyExperts <- ggplot(CMRP, aes(x=Tau_Vanilla_rel_Legacy, rile_allexperts_std)) + geom_point(aes(color=partyfam, shape=partyfam), size=3) + scale_color_manual(values=c("grey70", "grey70", "grey60", "grey50", "grey40", "grey30", "grey20" , "grey10", "black"), guide='none')+ scale_shape_manual(values=c(71, 83, 68, 82, 76, 3, 65, 80, 67)) + theme(panel.background=element_rect(fill="white")) + geom_smooth(method="lm", color="black") + labs(x = "\nLeft-Right Position\nContent Analysis (Modelled)", y="Expert Surveys\nLeft-Right Position\n") + ylim(0,100) + xlim(-15, 15) + annotate("text", x=10, y=25, label="r = .82", size=5) + theme(axis.text.x=element_text(size=15)) + theme(axis.title.x=element_text(size=15)) + theme(axis.text.y=element_text(size=15)) + theme(axis.title.y=element_text(size=15)) + theme(plot.title=element_text(size=15)) + guides(shape=guide_legend(title="Party Family")) + theme(legend.text=element_text(size=15)) + theme(legend.title=element_text(size=15)) TaubyExperts #TIFF Format ggsave(file=sprintf("%s%s", outpath, "ch5-f3-VanillaTaubyExperts.tiff"), width=12, height=8, dpi=600) #PNG Format ggsave(file=sprintf("%s%s", outpath, "ch5-f3-VanillaTaubyExperts.png"), width=12, height=8, dpi=600) ##Figure 6.1 #AUSTRALIA Australia <- read.csv(file=sprintf("%s%s", inpath, "CMRP_Australia.csv")) Australia$partyfam <- reorder(Australia$partyfam, Australia$partyorder, mean, order=TRUE) Australia$pervote <- Australia$pervote*20 Australia.fig <- ggplot(Australia, aes(year, Tau_Vanilla_rel_Legacy)) + geom_point(aes(color=partyfam, size=pervote, shape=partyfam), show_guide=FALSE, alpha=.8) + theme(panel.background=element_rect(fill="white")) + labs(x = "Year", y=" Left-Right Position ") + scale_y_continuous(limits=c(-29,15), breaks=c(-15, -10, -5, 0, 5, 10, 15), labels=c("-15","-10", "-5", "0", "5", "10", "15")) + scale_x_continuous(limits=c(1941, 2010), breaks=c(1945, 1965, 1985, 2005)) + theme(axis.text.x=element_text(size=20)) + theme(axis.title.x=element_text(size=20)) + theme(axis.text.y=element_text(size=20)) + theme(axis.title.y=element_text(size=20)) + geom_ribbon(aes(ymin = Polarization_std_min, ymax=Polarization_std_max), color="grey10", alpha=.5) + geom_segment(x=1945, y=-17, xend=2010, yend=-17, color="grey10") + geom_segment(x=1945, y=-23, xend=2010, yend=-23, color="grey10") + geom_segment(x=1945, y=-29, xend=2010, yend=-29, color="grey10") + annotate("text", x=1941, y=-17, label="3~sigma", parse=TRUE, size=7) + annotate("text", x=1941, y=-23, label="mu[Omega]", parse=TRUE, size=7) + annotate("text", x=1941, y=-29, label="-3~sigma", parse=TRUE, size=7) + annotate("text", x=1976, y=-15, label="POLARIZATION", size=8) + theme(plot.title=element_text(size=25)) + labs(title="Australia") + scale_color_manual(values=c("grey70", "grey60","grey20","grey10"), drop=FALSE) + scale_shape_manual(values=c(71, 68, 65, 67)) + scale_size_identity() Australia.fig ggsave(file=sprintf("%s%s", outpath, "ch6-f1a-CMRP_scatter_Australia.png"), width=7, height=7, dpi=600, scale=.8) ggsave(file=sprintf("%s%s", outpath, "ch6-f1a-CMRP_scatter_Australia.tiff"), width=7, height=7, dpi=600, scale=.8) #Austria Austria <- read.csv(file=sprintf("%s%s", inpath, "CMRP_Austria.csv")) Austria$partyfam <- reorder(Austria$partyfam, Austria$partyorder, mean, order=TRUE) Austria$pervote <- Austria$pervote*20 Austria.fig <- ggplot(Austria, aes(year, Tau_Vanilla_rel_Legacy)) + geom_point(aes(color=partyfam, size=pervote, shape=partyfam), show_guide=FALSE, alpha=.8) + theme(panel.background=element_rect(fill="white")) + labs(x = "Year", y=" Left-Right Position ") + scale_y_continuous(limits=c(-29,15), breaks=c(-15, -10, -5, 0, 5, 10, 15), labels=c("-15","-10", "-5", "0", "5", "10", "15")) + scale_x_continuous(limits=c(1941, 2010), breaks=c(1945, 1965, 1985, 2005)) + theme(axis.text.x=element_text(size=20)) + theme(axis.title.x=element_text(size=20)) + theme(axis.text.y=element_text(size=20)) + theme(axis.title.y=element_text(size=20)) + geom_ribbon(aes(ymin = Polarization_std_min, ymax=Polarization_std_max), color="grey10", alpha=.5) + geom_segment(x=1945, y=-17, xend=2010, yend=-17, color="grey10") + geom_segment(x=1945, y=-23, xend=2010, yend=-23, color="grey10") + geom_segment(x=1945, y=-29, xend=2010, yend=-29, color="grey10") + annotate("text", x=1941, y=-17, label="3~sigma", parse=TRUE, size=7) + annotate("text", x=1941, y=-23, label="mu[Omega]", parse=TRUE, size=7) + annotate("text", x=1941, y=-29, label="-3~sigma", parse=TRUE, size=7) + annotate("text", x=1976, y=-15, label="POLARIZATION", size=8) + theme(plot.title=element_text(size=25)) + labs(title="Austria") + scale_color_manual(values=c("grey70", "grey70", "grey60","grey40","grey30", "grey10"), drop=FALSE) + scale_shape_manual(values=c(71, 83, 68, 76, 3, 66)) + scale_size_identity() Austria.fig ggsave(file=sprintf("%s%s", outpath, "ch6-f1b-CMRP_scatter_Austria.png"), width=7, height=7, dpi=600, scale=.8) ggsave(file=sprintf("%s%s", outpath, "ch6-f1b-CMRP_scatter_Austria.tiff"), width=7, height=7, dpi=600, scale=.8) #Belgium Belgium <- read.csv(file=sprintf("%s%s", inpath, "CMRP_Belgium.csv")) Belgium$partyfam <- reorder(Belgium$partyfam, Belgium$partyorder, mean, order=TRUE) Belgium$pervote <- Belgium$pervote*20 Belgium.fig <- ggplot(Belgium, aes(year, Tau_Vanilla_rel_Legacy)) + geom_point(aes(color=partyfam, size=pervote, shape=partyfam), show_guide=FALSE, alpha=.8) + theme(panel.background=element_rect(fill="white")) + labs(x = "Year", y=" Left-Right Position ") + scale_y_continuous(limits=c(-29,15), breaks=c(-15, -10, -5, 0, 5, 10, 15), labels=c("-15","-10", "-5", "0", "5", "10", "15")) + scale_x_continuous(limits=c(1941, 2010), breaks=c(1945, 1965, 1985, 2005)) + theme(axis.text.x=element_text(size=20)) + theme(axis.title.x=element_text(size=20)) + theme(axis.text.y=element_text(size=20)) + theme(axis.title.y=element_text(size=20)) + geom_ribbon(aes(ymin = Polarization_std_min, ymax=Polarization_std_max), color="grey10", alpha=.5) + geom_segment(x=1945, y=-17, xend=2010, yend=-17, color="grey10") + geom_segment(x=1945, y=-23, xend=2010, yend=-23, color="grey10") + geom_segment(x=1945, y=-29, xend=2010, yend=-29, color="grey10") + annotate("text", x=1941, y=-17, label="3~sigma", parse=TRUE, size=7) + annotate("text", x=1941, y=-23, label="mu[Omega]", parse=TRUE, size=7) + annotate("text", x=1941, y=-29, label="-3~sigma", parse=TRUE, size=7) + annotate("text", x=1976, y=-15, label="POLARIZATION", size=8) + theme(plot.title=element_text(size=25)) + labs(title="Belgium") + scale_color_manual(values=c("grey70", "grey70", "grey60","grey50", "grey40","grey30"), drop=FALSE) + scale_shape_manual(values=c(71, 83, 68, 82, 76, 3))+ scale_size_identity() Belgium.fig ggsave(file=sprintf("%s%s", outpath, "ch6-f1c-CMRP_scatter_Belgium.png"), width=7, height=7, dpi=600, scale=.8) ggsave(file=sprintf("%s%s", outpath, "ch6-f1c-CMRP_scatter_Belgium.tiff"), width=7, height=7, dpi=600, scale=.8) #Canada Canada <- read.csv(file=sprintf("%s%s", inpath, "CMRP_Canada.csv")) Canada$partyfam <- reorder(Canada$partyfam, Canada$partyorder, mean, order=TRUE) Canada$pervote <- Canada$pervote*20 Canada.fig <- ggplot(Canada, aes(year, Tau_Vanilla_rel_Legacy)) + geom_point(aes(color=partyfam, size=pervote, shape=partyfam), show_guide=FALSE, alpha=.8) + theme(panel.background=element_rect(fill="white")) + labs(x = "Year", y=" Left-Right Position ") + scale_y_continuous(limits=c(-29,15), breaks=c(-15, -10, -5, 0, 5, 10, 15), labels=c("-15","-10", "-5", "0", "5", "10", "15")) + scale_x_continuous(limits=c(1941, 2010), breaks=c(1945, 1965, 1985, 2005)) + theme(axis.text.x=element_text(size=20)) + theme(axis.title.x=element_text(size=20)) + theme(axis.text.y=element_text(size=20)) + theme(axis.title.y=element_text(size=20)) + geom_ribbon(aes(ymin = Polarization_std_min, ymax=Polarization_std_max), color="grey10", alpha=.5) + geom_segment(x=1945, y=-17, xend=2010, yend=-17, color="grey10") + geom_segment(x=1945, y=-23, xend=2010, yend=-23, color="grey10") + geom_segment(x=1945, y=-29, xend=2010, yend=-29, color="grey10") + annotate("text", x=1941, y=-17, label="3~sigma", parse=TRUE, size=7) + annotate("text", x=1941, y=-23, label="mu[Omega]", parse=TRUE, size=7) + annotate("text", x=1941, y=-29, label="-3~sigma", parse=TRUE, size=7) + annotate("text", x=1976, y=-15, label="POLARIZATION", size=8) + theme(plot.title=element_text(size=25)) + labs(title="Canada") + scale_color_manual(values=c("grey70", "grey60", "grey50", "grey40","grey10", "black"), drop=FALSE) + scale_shape_manual(values=c(71, 68, 82, 76, 80, 67))+ scale_size_identity() Canada.fig ggsave(file=sprintf("%s%s", outpath, "ch6-f1d-CMRP_scatter_Canada.png"), width=7, height=7, dpi=600, scale=.8) ggsave(file=sprintf("%s%s", outpath, "ch6-f1d-CMRP_scatter_Canada.tiff"), width=7, height=7, dpi=600, scale=.8) ###########DENMARK Denmark <- read.csv(file=sprintf("%s%s", inpath, "CMRP_Denmark.csv")) Denmark$partyfam <- reorder(Denmark$partyfam, Denmark$partyorder, mean, order=TRUE) Denmark$pervote <- Denmark$pervote*20 Denmark.fig <- ggplot(Denmark, aes(year, Tau_Vanilla_rel_Legacy)) + geom_point(aes(color=partyfam, size=pervote, shape=partyfam), show_guide=FALSE, alpha=.8) + theme(panel.background=element_rect(fill="white")) + labs(x = "Year", y=" Left-Right Position ") + scale_y_continuous(limits=c(-29,15), breaks=c(-15, -10, -5, 0, 5, 10, 15), labels=c("-15","-10", "-5", "0", "5", "10", "15")) + scale_x_continuous(limits=c(1941, 2010), breaks=c(1945, 1965, 1985, 2005)) + theme(axis.text.x=element_text(size=20)) + theme(axis.title.x=element_text(size=20)) + theme(axis.text.y=element_text(size=20)) + theme(axis.title.y=element_text(size=20)) + geom_ribbon(aes(ymin = Polarization_std_min, ymax=Polarization_std_max), color="grey10", alpha=.5) + geom_segment(x=1945, y=-17, xend=2010, yend=-17, color="grey10") + geom_segment(x=1945, y=-23, xend=2010, yend=-23, color="grey10") + geom_segment(x=1945, y=-29, xend=2010, yend=-29, color="grey10") + annotate("text", x=1941, y=-17, label="3~sigma", parse=TRUE, size=7) + annotate("text", x=1941, y=-23, label="mu[Omega]", parse=TRUE, size=7) + annotate("text", x=1941, y=-29, label="-3~sigma", parse=TRUE, size=7) + annotate("text", x=1976, y=-15, label="POLARIZATION", size=8) + theme(plot.title=element_text(size=25)) + labs(title="Denmark") + scale_color_manual(values=c("grey70", "grey60","grey40","grey30", "grey10", "black"), drop=FALSE) + scale_shape_manual(values=c(83, 68, 76, 3, 80, 67))+ scale_size_identity() Denmark.fig ggsave(file=sprintf("%s%s", outpath, "ch6-f1e-CMRP_scatter_Denmark.png"), width=7, height=7, dpi=600, scale=.8) ggsave(file=sprintf("%s%s", outpath, "ch6-f1c-CMRP_scatter_Denmark.tiff"), width=7, height=7, dpi=600, scale=.8) #############FINLAND #Finland Finland <- read.csv(file=sprintf("%s%s", inpath, "CMRP_Finland.csv")) Finland$partyfam <- reorder(Finland$partyfam, Finland$partyorder, mean, order=TRUE) Finland$pervote <- Finland$pervote * 20 Finland.fig <- ggplot(Finland, aes(year, Tau_Vanilla_rel_Legacy)) + geom_point(aes(color=partyfam, size=pervote, shape=partyfam), show_guide=FALSE, alpha=.8) + theme(panel.background=element_rect(fill="white")) + labs(x = "Year", y=" Left-Right Position ") + scale_y_continuous(limits=c(-29,15), breaks=c(-15, -10, -5, 0, 5, 10, 15), labels=c("-15","-10", "-5", "0", "5", "10", "15")) + scale_x_continuous(limits=c(1941, 2010), breaks=c(1945, 1965, 1985, 2005)) + theme(axis.text.x=element_text(size=20)) + theme(axis.title.x=element_text(size=20)) + theme(axis.text.y=element_text(size=20)) + theme(axis.title.y=element_text(size=20)) + geom_ribbon(aes(ymin = Polarization_std_min, ymax=Polarization_std_max), color="grey10", alpha=.5) + geom_segment(x=1945, y=-17, xend=2010, yend=-17, color="grey10") + geom_segment(x=1945, y=-23, xend=2010, yend=-23, color="grey10") + geom_segment(x=1945, y=-29, xend=2010, yend=-29, color="grey10") + annotate("text", x=1941, y=-17, label="3~sigma", parse=TRUE, size=7) + annotate("text", x=1941, y=-23, label="mu[Omega]", parse=TRUE, size=7) + annotate("text", x=1941, y=-29, label="-3~sigma", parse=TRUE, size=7) + annotate("text", x=1976, y=-15, label="POLARIZATION", size=8) + theme(plot.title=element_text(size=25)) + labs(title="Finland") + scale_color_manual(values=c("grey70", "grey70", "grey60","grey50", "grey40","grey30", "grey20", "black"), drop=FALSE)+ scale_shape_manual(values=c(71, 83, 68, 82, 76, 3, 65, 67))+ scale_size_identity() Finland.fig ggsave(file=sprintf("%s%s", outpath, "ch6-f1f-CMRP_scatter_Finland.png"), width=7, height=7, dpi=600, scale=.8) ggsave(file=sprintf("%s%s", outpath, "ch6-f1c-CMRP_scatter_Finland.tiff"), width=7, height=7, dpi=600, scale=.8) ############FRANCE #France France <- read.csv(file=sprintf("%s%s", inpath, "CMRP_France.csv")) France$partyfam <- reorder(France$partyfam, France$partyorder, mean, order=TRUE) France$pervote <- France$pervote*20 France.fig <- ggplot(France, aes(year, Tau_Vanilla_rel_Legacy)) + geom_point(aes(color=partyfam, size=pervote, shape=partyfam), show_guide=FALSE, alpha=.8) + theme(panel.background=element_rect(fill="white")) + labs(x = "Year", y=" Left-Right Position ") + scale_y_continuous(limits=c(-29,15), breaks=c(-15, -10, -5, 0, 5, 10, 15), labels=c("-15","-10", "-5", "0", "5", "10", "15")) + scale_x_continuous(limits=c(1941, 2010), breaks=c(1945, 1965, 1985, 2005)) + theme(axis.text.x=element_text(size=20)) + theme(axis.title.x=element_text(size=20)) + theme(axis.text.y=element_text(size=20)) + theme(axis.title.y=element_text(size=20)) + geom_ribbon(aes(ymin = Polarization_std_min, ymax=Polarization_std_max), color="grey10", alpha=.5) + geom_segment(x=1945, y=-17, xend=2010, yend=-17, color="grey10") + geom_segment(x=1945, y=-23, xend=2010, yend=-23, color="grey10") + geom_segment(x=1945, y=-29, xend=2010, yend=-29, color="grey10") + annotate("text", x=1941, y=-17, label="3~sigma", parse=TRUE, size=7) + annotate("text", x=1941, y=-23, label="mu[Omega]", parse=TRUE, size=7) + annotate("text", x=1941, y=-29, label="-3~sigma", parse=TRUE, size=7) + annotate("text", x=1976, y=-15, label="POLARIZATION", size=8) + theme(plot.title=element_text(size=25)) + labs(title="France") + scale_color_manual(values=c("grey70", "grey70", "grey60","grey40","grey30", "grey10", "black"), drop=FALSE)+ scale_shape_manual(values=c(71, 83, 68, 76, 3, 80, 67)) + scale_size_identity() France.fig ggsave(file=sprintf("%s%s", outpath, "ch6-f1g-CMRP_scatter_France.png"), width=7, height=7, dpi=600, scale=.8) ggsave(file=sprintf("%s%s", outpath, "ch6-f1c-CMRP_scatter_France.tiff"), width=7, height=7, dpi=600, scale=.8) ####GERMANY #Germany Germany <- read.csv(file=sprintf("%s%s", inpath, "CMRP_Germany.csv")) Germany$partyfam <- reorder(Germany$partyfam, Germany$partyorder, mean, order=TRUE) Germany$pervote <- Germany$pervote*20 Germany.fig <- ggplot(Germany, aes(year, Tau_Vanilla_rel_Legacy)) + geom_point(aes(color=partyfam, size=pervote, shape=partyfam), show_guide=FALSE, alpha=.8) + theme(panel.background=element_rect(fill="white")) + labs(x = "Year", y=" Left-Right Position ") + scale_y_continuous(limits=c(-29,15), breaks=c(-15, -10, -5, 0, 5, 10, 15), labels=c("-15","-10", "-5", "0", "5", "10", "15")) + scale_x_continuous(limits=c(1941, 2010), breaks=c(1945, 1965, 1985, 2005)) + theme(axis.text.x=element_text(size=20)) + theme(axis.title.x=element_text(size=20)) + theme(axis.text.y=element_text(size=20)) + theme(axis.title.y=element_text(size=20)) + geom_ribbon(aes(ymin = Polarization_std_min, ymax=Polarization_std_max), color="grey10", alpha=.5) + geom_segment(x=1945, y=-17, xend=2010, yend=-17, color="grey10") + geom_segment(x=1945, y=-23, xend=2010, yend=-23, color="grey10") + geom_segment(x=1945, y=-29, xend=2010, yend=-29, color="grey10") + annotate("text", x=1941, y=-17, label="3~sigma", parse=TRUE, size=7) + annotate("text", x=1941, y=-23, label="mu[Omega]", parse=TRUE, size=7) + annotate("text", x=1941, y=-29, label="-3~sigma", parse=TRUE, size=7) + annotate("text", x=1976, y=-15, label="POLARIZATION", size=8) + theme(plot.title=element_text(size=25)) + labs(title="Germany") + scale_color_manual(values=c("grey70", "grey70", "grey60", "grey50", "grey40","grey30", "grey10", "black"), drop=FALSE)+ scale_shape_manual(values=c(71, 83, 68, 82, 76, 3, 80, 67)) + scale_size_identity() Germany.fig ggsave(file=sprintf("%s%s", outpath, "ch6-f1h-CMRP_scatter_Germany.png"), width=7, height=7, dpi=600, scale=.8) ggsave(file=sprintf("%s%s", outpath, "ch6-f1c-CMRP_scatter_Germany.tiff"), width=7, height=7, dpi=600, scale=.8) ##############Great Britain #Britain Britain <- read.csv(file=sprintf("%s%s", inpath, "CMRP_Britain.csv")) Britain$partyfam <- reorder(Britain$partyfam, Britain$partyorder, mean, order=TRUE) Britain$pervote <- Britain$pervote*20 Britain.fig <- ggplot(Britain, aes(year, Tau_Vanilla_rel_Legacy)) + geom_point(aes(color=partyfam, size=pervote, shape=partyfam), show_guide=FALSE, alpha=.8) + theme(panel.background=element_rect(fill="white")) + labs(x = "Year", y=" Left-Right Position ") + scale_y_continuous(limits=c(-29,15), breaks=c(-15, -10, -5, 0, 5, 10, 15), labels=c("-15","-10", "-5", "0", "5", "10", "15")) + scale_x_continuous(limits=c(1941, 2010), breaks=c(1945, 1965, 1985, 2005)) + theme(axis.text.x=element_text(size=20)) + theme(axis.title.x=element_text(size=20)) + theme(axis.text.y=element_text(size=20)) + theme(axis.title.y=element_text(size=20)) + geom_ribbon(aes(ymin = Polarization_std_min, ymax=Polarization_std_max), color="grey10", alpha=.5) + geom_segment(x=1945, y=-17, xend=2010, yend=-17, color="grey10") + geom_segment(x=1945, y=-23, xend=2010, yend=-23, color="grey10") + geom_segment(x=1945, y=-29, xend=2010, yend=-29, color="grey10") + annotate("text", x=1941, y=-17, label="3~sigma", parse=TRUE, size=7) + annotate("text", x=1941, y=-23, label="mu[Omega]", parse=TRUE, size=7) + annotate("text", x=1941, y=-29, label="-3~sigma", parse=TRUE, size=7) + annotate("text", x=1976, y=-15, label="POLARIZATION", size=8) + theme(plot.title=element_text(size=25)) + labs(title="Great Britain") + scale_color_manual(values=c("grey70", "grey60", "grey50", "grey40", "grey10", "black"), drop=FALSE)+ scale_shape_manual(values=c(83, 68, 82, 76, 80, 67))+ scale_size_identity() Britain.fig ggsave(file=sprintf("%s%s", outpath, "ch6-f1i-CMRP_scatter_Britain.png"), width=7, height=7, dpi=600, scale=.8) ggsave(file=sprintf("%s%s", outpath, "ch6-f1c-CMRP_scatter_Britain.tiff"), width=7, height=7, dpi=600, scale=.8) #######GREECE #Greece Greece <- read.csv(file=sprintf("%s%s", inpath, "CMRP_Greece.csv")) Greece$partyfam <- reorder(Greece$partyfam, Greece$partyorder, mean, order=TRUE) Greece$pervote <- Greece$pervote*20 Greece.fig <- ggplot(Greece, aes(year, Tau_Vanilla_rel_Legacy)) + geom_point(aes(color=partyfam, size=pervote, shape=partyfam), show_guide=FALSE, alpha=.8) + theme(panel.background=element_rect(fill="white")) + labs(x = "Year", y=" Left-Right Position ") + scale_y_continuous(limits=c(-29,15), breaks=c(-15, -10, -5, 0, 5, 10, 15), labels=c("-15","-10", "-5", "0", "5", "10", "15")) + scale_x_continuous(limits=c(1941, 2010), breaks=c(1945, 1965, 1985, 2005)) + theme(axis.text.x=element_text(size=20)) + theme(axis.title.x=element_text(size=20)) + theme(axis.text.y=element_text(size=20)) + theme(axis.title.y=element_text(size=20)) + geom_ribbon(aes(ymin = Polarization_std_min, ymax=Polarization_std_max), color="grey10", alpha=.5) + geom_segment(x=1945, y=-17, xend=2010, yend=-17, color="grey10") + geom_segment(x=1945, y=-23, xend=2010, yend=-23, color="grey10") + geom_segment(x=1945, y=-29, xend=2010, yend=-29, color="grey10") + annotate("text", x=1941, y=-17, label="3~sigma", parse=TRUE, size=7) + annotate("text", x=1941, y=-23, label="mu[Omega]", parse=TRUE, size=7) + annotate("text", x=1941, y=-29, label="-3~sigma", parse=TRUE, size=7) + annotate("text", x=1976, y=-15, label="POLARIZATION", size=8) + theme(plot.title=element_text(size=25)) + labs(title="Greece") + scale_color_manual(values=c("grey70", "grey60","grey30","black"), drop=FALSE)+ scale_shape_manual(values=c(83, 68, 3, 67)) + scale_size_identity() Greece.fig ggsave(file=sprintf("%s%s", outpath, "ch6-f1j-CMRP_scatter_Greece.png"), width=7, height=7, dpi=600, scale=.8) ggsave(file=sprintf("%s%s", outpath, "ch6-f1c-CMRP_scatter_Greece.tiff"), width=7, height=7, dpi=600, scale=.8) ###ICELAND #Iceland Iceland <- read.csv(file=sprintf("%s%s", inpath, "CMRP_Iceland.csv")) Iceland$partyfam <- reorder(Iceland$partyfam, Iceland$partyorder, mean, order=TRUE) Iceland$pervote <- Iceland$pervote*20 Iceland.fig <- ggplot(Iceland, aes(year, Tau_Vanilla_rel_Legacy)) + geom_point(aes(color=partyfam, size=pervote, shape=partyfam), show_guide=FALSE, alpha=.8) + theme(panel.background=element_rect(fill="white")) + labs(x = "Year", y=" Left-Right Position ") + scale_y_continuous(limits=c(-29,15), breaks=c(-15, -10, -5, 0, 5, 10, 15), labels=c("-15","-10", "-5", "0", "5", "10", "15")) + scale_x_continuous(limits=c(1941, 2010), breaks=c(1945, 1965, 1985, 2005)) + theme(axis.text.x=element_text(size=20)) + theme(axis.title.x=element_text(size=20)) + theme(axis.text.y=element_text(size=20)) + theme(axis.title.y=element_text(size=20)) + geom_ribbon(aes(ymin = Polarization_std_min, ymax=Polarization_std_max), color="grey10", alpha=.5) + geom_segment(x=1945, y=-17, xend=2010, yend=-17, color="grey10") + geom_segment(x=1945, y=-23, xend=2010, yend=-23, color="grey10") + geom_segment(x=1945, y=-29, xend=2010, yend=-29, color="grey10") + annotate("text", x=1941, y=-17, label="3~sigma", parse=TRUE, size=7) + annotate("text", x=1941, y=-23, label="mu[Omega]", parse=TRUE, size=7) + annotate("text", x=1941, y=-29, label="-3~sigma", parse=TRUE, size=7) + annotate("text", x=1976, y=-15, label="POLARIZATION", size=8) + theme(plot.title=element_text(size=25)) + labs(title="Iceland") + scale_color_manual(values=c("grey70", "grey70", "grey60","grey40","grey20", "grey10", "black"), drop=FALSE)+ scale_shape_manual(values=c(71, 83, 68, 76, 65, 80, 67))+ scale_size_identity() Iceland.fig ggsave(file=sprintf("%s%s", outpath, "ch6-f1k-CMRP_scatter_Iceland.png"), width=7, height=7, dpi=600, scale=.8) ggsave(file=sprintf("%s%s", outpath, "ch6-f1c-CMRP_scatter_Iceland.tiff"), width=7, height=7, dpi=600, scale=.8) ##IRELAND #Ireland Ireland <- read.csv(file=sprintf("%s%s", inpath, "CMRP_Ireland.csv")) Ireland$partyfam <- reorder(Ireland$partyfam, Ireland$partyorder, mean, order=TRUE) Ireland$pervote <- Ireland$pervote*20 Ireland.fig <- ggplot(Ireland, aes(year, Tau_Vanilla_rel_Legacy)) + geom_point(aes(color=partyfam, size=pervote, shape=partyfam), show_guide=FALSE, alpha=.8) + theme(panel.background=element_rect(fill="white")) + labs(x = "Year", y=" Left-Right Position ") + scale_y_continuous(limits=c(-29,15), breaks=c(-15, -10, -5, 0, 5, 10, 15), labels=c("-15","-10", "-5", "0", "5", "10", "15")) + scale_x_continuous(limits=c(1941, 2010), breaks=c(1945, 1965, 1985, 2005)) + theme(axis.text.x=element_text(size=20)) + theme(axis.title.x=element_text(size=20)) + theme(axis.text.y=element_text(size=20)) + theme(axis.title.y=element_text(size=20)) + geom_ribbon(aes(ymin = Polarization_std_min, ymax=Polarization_std_max), color="grey10", alpha=.5) + geom_segment(x=1945, y=-17, xend=2010, yend=-17, color="grey10") + geom_segment(x=1945, y=-23, xend=2010, yend=-23, color="grey10") + geom_segment(x=1945, y=-29, xend=2010, yend=-29, color="grey10") + annotate("text", x=1941, y=-17, label="3~sigma", parse=TRUE, size=7) + annotate("text", x=1941, y=-23, label="mu[Omega]", parse=TRUE, size=7) + annotate("text", x=1941, y=-29, label="-3~sigma", parse=TRUE, size=7) + annotate("text", x=1976, y=-15, label="POLARIZATION", size=8) + theme(plot.title=element_text(size=25)) + labs(title="Ireland") + scale_color_manual(values=c("grey70", "grey70", "grey60","grey40","grey30", "grey20", "grey10", "black"), drop=FALSE)+ scale_shape_manual(values=c(71, 83, 68, 76, 3, 65, 80, 67))+ scale_size_identity() Ireland.fig ggsave(file=sprintf("%s%s", outpath, "ch6-f1l-CMRP_scatter_Ireland.png"), width=7, height=7, dpi=600, scale=.8) ggsave(file=sprintf("%s%s", outpath, "ch6-f1c-CMRP_scatter_Ireland.tiff"), width=7, height=7, dpi=600, scale=.8) #### ITALY #Italy Italy <- read.csv(file=sprintf("%s%s", inpath, "CMRP_Italy.csv")) Italy$partyfam <- reorder(Italy$partyfam, Italy$partyorder, mean, order=TRUE) Italy$pervote <- Italy$pervote*20 Italy.fig <- ggplot(Italy, aes(year, Tau_Vanilla_rel_Legacy)) + geom_point(aes(color=partyfam, size=pervote, shape=partyfam), show_guide=FALSE, alpha=.8) + theme(panel.background=element_rect(fill="white")) + labs(x = "Year", y=" Left-Right Position ") + scale_y_continuous(limits=c(-29,15), breaks=c(-15, -10, -5, 0, 5, 10, 15), labels=c("-15","-10", "-5", "0", "5", "10", "15")) + scale_x_continuous(limits=c(1941, 2010), breaks=c(1945, 1965, 1985, 2005)) + theme(axis.text.x=element_text(size=20)) + theme(axis.title.x=element_text(size=20)) + theme(axis.text.y=element_text(size=20)) + theme(axis.title.y=element_text(size=20)) + geom_ribbon(aes(ymin = Polarization_std_min, ymax=Polarization_std_max), color="grey10", alpha=.5) + geom_segment(x=1945, y=-17, xend=2010, yend=-17, color="grey10") + geom_segment(x=1945, y=-23, xend=2010, yend=-23, color="grey10") + geom_segment(x=1945, y=-29, xend=2010, yend=-29, color="grey10") + annotate("text", x=1941, y=-17, label="3~sigma", parse=TRUE, size=7) + annotate("text", x=1941, y=-23, label="mu[Omega]", parse=TRUE, size=7) + annotate("text", x=1941, y=-29, label="-3~sigma", parse=TRUE, size=7) + annotate("text", x=1976, y=-15, label="POLARIZATION", size=8) + theme(plot.title=element_text(size=25)) + labs(title="Italy") + scale_color_manual(values=c("grey70", "grey70", "grey60","grey50", "grey40","grey30", "grey10", "black"), drop=FALSE)+ scale_shape_manual(values=c(71, 83, 68, 82, 76, 3, 65, 80, 67))+ scale_size_identity() Italy.fig ggsave(file=sprintf("%s%s", outpath, "ch6-f1m-CMRP_scatter_Italy.png"), width=7, height=7, dpi=600, scale=.8) ggsave(file=sprintf("%s%s", outpath, "ch6-f1m-CMRP_scatter_Italy.tiff"), width=7, height=7, dpi=600, scale=.8) #Luxembourg Luxembourg <- read.csv(file=sprintf("%s%s", inpath, "CMRP_Luxembourg.csv")) Luxembourg$partyfam <- reorder(Luxembourg$partyfam, Luxembourg$partyorder, mean, order=TRUE) Luxembourg$pervote <- Luxembourg$pervote*20 Luxembourg.fig <- ggplot(Luxembourg, aes(year, Tau_Vanilla_rel_Legacy)) + geom_point(aes(color=partyfam, size=pervote, shape=partyfam), show_guide=FALSE, alpha=.8) + theme(panel.background=element_rect(fill="white")) + labs(x = "Year", y=" Left-Right Position ") + scale_y_continuous(limits=c(-29,15), breaks=c(-15, -10, -5, 0, 5, 10, 15), labels=c("-15","-10", "-5", "0", "5", "10", "15")) + scale_x_continuous(limits=c(1941, 2010), breaks=c(1945, 1965, 1985, 2005)) + theme(axis.text.x=element_text(size=20)) + theme(axis.title.x=element_text(size=20)) + theme(axis.text.y=element_text(size=20)) + theme(axis.title.y=element_text(size=20)) + geom_ribbon(aes(ymin = Polarization_std_min, ymax=Polarization_std_max), color="grey10", alpha=.5) + geom_segment(x=1945, y=-17, xend=2010, yend=-17, color="grey10") + geom_segment(x=1945, y=-23, xend=2010, yend=-23, color="grey10") + geom_segment(x=1945, y=-29, xend=2010, yend=-29, color="grey10") + annotate("text", x=1941, y=-17, label="3~sigma", parse=TRUE, size=7) + annotate("text", x=1941, y=-23, label="mu[Omega]", parse=TRUE, size=7) + annotate("text", x=1941, y=-29, label="-3~sigma", parse=TRUE, size=7) + annotate("text", x=1976, y=-15, label="POLARIZATION", size=8) + theme(plot.title=element_text(size=25)) + labs(title="Luxembourg") + scale_color_manual(values=c("grey70", "grey70", "grey60","grey40","grey30", "grey10"), drop=FALSE)+ scale_shape_manual(values=c(71, 83, 68, 76, 3, 80))+ scale_size_identity() Luxembourg.fig ggsave(file=sprintf("%s%s", outpath, "ch6-f1n-CMRP_scatter_Luxembourg.png"), width=7, height=7, dpi=600, scale=.8) ggsave(file=sprintf("%s%s", outpath, "ch6-f1n-CMRP_scatter_Luxembourg.tiff"), width=7, height=7, dpi=600, scale=.8) #Netherlands #Netherlands Netherlands <- read.csv(file=sprintf("%s%s", inpath, "CMRP_Netherlands.csv")) Netherlands$partyfam <- reorder(Netherlands$partyfam, Netherlands$partyorder, mean, order=TRUE) Netherlands$pervote <- Netherlands$pervote*20 Netherlands.fig <- ggplot(Netherlands, aes(year, Tau_Vanilla_rel_Legacy)) + geom_point(aes(color=partyfam, size=pervote, shape=partyfam), show_guide=FALSE, alpha=.8) + theme(panel.background=element_rect(fill="white")) + labs(x = "Year", y=" Left-Right Position ") + scale_y_continuous(limits=c(-29,15), breaks=c(-15, -10, -5, 0, 5, 10, 15), labels=c("-15","-10", "-5", "0", "5", "10", "15")) + scale_x_continuous(limits=c(1941, 2010), breaks=c(1945, 1965, 1985, 2005)) + theme(axis.text.x=element_text(size=20)) + theme(axis.title.x=element_text(size=20)) + theme(axis.text.y=element_text(size=20)) + theme(axis.title.y=element_text(size=20)) + geom_ribbon(aes(ymin = Polarization_std_min, ymax=Polarization_std_max), color="grey10", alpha=.5) + geom_segment(x=1945, y=-17, xend=2010, yend=-17, color="grey10") + geom_segment(x=1945, y=-23, xend=2010, yend=-23, color="grey10") + geom_segment(x=1945, y=-29, xend=2010, yend=-29, color="grey10") + annotate("text", x=1941, y=-17, label="3~sigma", parse=TRUE, size=7) + annotate("text", x=1941, y=-23, label="mu[Omega]", parse=TRUE, size=7) + annotate("text", x=1941, y=-29, label="-3~sigma", parse=TRUE, size=7) + annotate("text", x=1976, y=-15, label="POLARIZATION", size=8) + theme(plot.title=element_text(size=25)) + labs(title="Netherlands") + scale_color_manual(values=c("grey70", "grey70", "grey60","grey40","grey30", "grey10"), drop=FALSE) + scale_shape_manual(values=c(71, 83, 68, 76, 3, 80))+ scale_size_identity() Netherlands.fig ggsave(file=sprintf("%s%s", outpath, "ch6-f1o-CMRP_scatter_Netherlands.png"), width=7, height=7, dpi=600, scale=.8) ggsave(file=sprintf("%s%s", outpath, "ch6-f1o-CMRP_scatter_Netherlands.tiff"), width=7, height=7, dpi=600, scale=.8) #NEW ZEALAND #NewZealand NewZealand <- read.csv(file=sprintf("%s%s", inpath, "CMRP_NewZealand.csv")) NewZealand$partyfam <- reorder(NewZealand$partyfam, NewZealand$partyorder, mean, order=TRUE) NewZealand$pervote <- NewZealand$pervote*20 NewZealand.fig <- ggplot(NewZealand, aes(year, Tau_Vanilla_rel_Legacy)) + geom_point(aes(color=partyfam, size=pervote, shape=partyfam), show_guide=FALSE, alpha=.8) + theme(panel.background=element_rect(fill="white")) + labs(x = "Year", y=" Left-Right Position ") + scale_y_continuous(limits=c(-29,15), breaks=c(-15, -10, -5, 0, 5, 10, 15), labels=c("-15","-10", "-5", "0", "5", "10", "15")) + scale_x_continuous(limits=c(1941, 2010), breaks=c(1945, 1965, 1985, 2005)) + theme(axis.text.x=element_text(size=20)) + theme(axis.title.x=element_text(size=20)) + theme(axis.text.y=element_text(size=20)) + theme(axis.title.y=element_text(size=20)) + geom_ribbon(aes(ymin = Polarization_std_min, ymax=Polarization_std_max), color="grey10", alpha=.5) + geom_segment(x=1945, y=-17, xend=2010, yend=-17, color="grey10") + geom_segment(x=1945, y=-23, xend=2010, yend=-23, color="grey10") + geom_segment(x=1945, y=-29, xend=2010, yend=-29, color="grey10") + annotate("text", x=1941, y=-17, label="3~sigma", parse=TRUE, size=7) + annotate("text", x=1941, y=-23, label="mu[Omega]", parse=TRUE, size=7) + annotate("text", x=1941, y=-29, label="-3~sigma", parse=TRUE, size=7) + annotate("text", x=1976, y=-15, label="POLARIZATION", size=8) + theme(plot.title=element_text(size=25)) + labs(title="NewZealand") + scale_color_manual(values=c("grey70", "grey60","grey40","grey10", "black"), drop=FALSE) + scale_shape_manual(values=c(71, 68, 76, 80, 67))+ scale_size_identity() NewZealand.fig ggsave(file=sprintf("%s%s", outpath, "ch6-f1p-CMRP_scatter_NewZealand.png"), width=7, height=7, dpi=600, scale=.8) ggsave(file=sprintf("%s%s", outpath, "ch6-f1p-CMRP_scatter_NewZealand.tiff"), width=7, height=7, dpi=600, scale=.8) ##########NORWAY #Norway Norway <- read.csv(file=sprintf("%s%s", inpath, "CMRP_Norway.csv")) Norway$partyfam <- reorder(Norway$partyfam, Norway$partyorder, mean, order=TRUE) Norway$pervote <- Norway$pervote*20 Norway.fig <- ggplot(Norway, aes(year, Tau_Vanilla_rel_Legacy)) + geom_point(aes(color=partyfam, size=pervote, shape=partyfam), show_guide=FALSE, alpha=.8) + theme(panel.background=element_rect(fill="white")) + labs(x = "Year", y=" Left-Right Position ") + scale_y_continuous(limits=c(-29,15), breaks=c(-15, -10, -5, 0, 5, 10, 15), labels=c("-15","-10", "-5", "0", "5", "10", "15")) + scale_x_continuous(limits=c(1941, 2010), breaks=c(1945, 1965, 1985, 2005)) + theme(axis.text.x=element_text(size=20)) + theme(axis.title.x=element_text(size=20)) + theme(axis.text.y=element_text(size=20)) + theme(axis.title.y=element_text(size=20)) + geom_ribbon(aes(ymin = Polarization_std_min, ymax=Polarization_std_max), color="grey10", alpha=.5) + geom_segment(x=1945, y=-17, xend=2010, yend=-17, color="grey10") + geom_segment(x=1945, y=-23, xend=2010, yend=-23, color="grey10") + geom_segment(x=1945, y=-29, xend=2010, yend=-29, color="grey10") + annotate("text", x=1941, y=-17, label="3~sigma", parse=TRUE, size=7) + annotate("text", x=1941, y=-23, label="mu[Omega]", parse=TRUE, size=7) + annotate("text", x=1941, y=-29, label="-3~sigma", parse=TRUE, size=7) + annotate("text", x=1976, y=-15, label="POLARIZATION", size=8) + theme(plot.title=element_text(size=25)) + labs(title="Norway") + scale_color_manual(values=c("grey70", "grey60","grey40","grey30", "grey20" ,"grey10", "black"), drop=FALSE)+ scale_shape_manual(values=c(83, 68, 76, 3, 65, 80, 67))+ scale_size_identity() Norway.fig ggsave(file=sprintf("%s%s", outpath, "ch6-f1q-CMRP_scatter_Norway.png"), width=7, height=7, dpi=600, scale=.8) ggsave(file=sprintf("%s%s", outpath, "ch6-f1q-CMRP_scatter_Norway.tiff"), width=7, height=7, dpi=600, scale=.8) #Portugal Portugal <- read.csv(file=sprintf("%s%s", inpath, "CMRP_Portugal.csv")) Portugal$partyfam <- reorder(Portugal$partyfam, Portugal$partyorder, mean, order=TRUE) Portugal$pervote <- Portugal$pervote*20 Portugal.fig <- ggplot(Portugal, aes(year, Tau_Vanilla_rel_Legacy)) + geom_point(aes(color=partyfam, size=pervote, shape=partyfam), show_guide=FALSE, alpha=.8) + theme(panel.background=element_rect(fill="white")) + labs(x = "Year", y=" Left-Right Position ") + scale_y_continuous(limits=c(-29,15), breaks=c(-15, -10, -5, 0, 5, 10, 15), labels=c("-15","-10", "-5", "0", "5", "10", "15")) + scale_x_continuous(limits=c(1941, 2010), breaks=c(1945, 1965, 1985, 2005)) + theme(axis.text.x=element_text(size=20)) + theme(axis.title.x=element_text(size=20)) + theme(axis.text.y=element_text(size=20)) + theme(axis.title.y=element_text(size=20)) + geom_ribbon(aes(ymin = Polarization_std_min, ymax=Polarization_std_max), color="grey10", alpha=.5) + geom_segment(x=1945, y=-17, xend=2010, yend=-17, color="grey10") + geom_segment(x=1945, y=-23, xend=2010, yend=-23, color="grey10") + geom_segment(x=1945, y=-29, xend=2010, yend=-29, color="grey10") + annotate("text", x=1941, y=-17, label="3~sigma", parse=TRUE, size=7) + annotate("text", x=1941, y=-23, label="mu[Omega]", parse=TRUE, size=7) + annotate("text", x=1941, y=-29, label="-3~sigma", parse=TRUE, size=7) + annotate("text", x=1976, y=-15, label="POLARIZATION", size=8) + theme(plot.title=element_text(size=25)) + labs(title="Portugal") + scale_color_manual(values=c("grey70", "grey70", "grey60","grey30", "grey20", "grey10"), drop=FALSE) + scale_shape_manual(values=c(71, 83, 68, 3, 65, 80))+ scale_size_identity() Portugal.fig ggsave(file=sprintf("%s%s", outpath, "ch6-f1r-CMRP_scatter_Portugal.png"), width=7, height=7, dpi=600, scale=.8) ggsave(file=sprintf("%s%s", outpath, "ch6-f1r-CMRP_scatter_Portugal.tiff"), width=7, height=7, dpi=600, scale=.8) ###########SPAIN #Spain Spain <- read.csv(file=sprintf("%s%s", inpath, "CMRP_Spain.csv")) Spain$partyfam <- reorder(Spain$partyfam, Spain$partyorder, mean, order=TRUE) Spain$pervote <- Spain$pervote*20 Spain.fig <- ggplot(Spain, aes(year, Tau_Vanilla_rel_Legacy)) + geom_point(aes(color=partyfam, size=pervote, shape=partyfam), show_guide=FALSE, alpha=.8) + theme(panel.background=element_rect(fill="white")) + labs(x = "Year", y=" Left-Right Position ") + scale_y_continuous(limits=c(-29,15), breaks=c(-15, -10, -5, 0, 5, 10, 15), labels=c("-15","-10", "-5", "0", "5", "10", "15")) + scale_x_continuous(limits=c(1941, 2010), breaks=c(1945, 1965, 1985, 2005)) + theme(axis.text.x=element_text(size=20)) + theme(axis.title.x=element_text(size=20)) + theme(axis.text.y=element_text(size=20)) + theme(axis.title.y=element_text(size=20)) + geom_ribbon(aes(ymin = Polarization_std_min, ymax=Polarization_std_max), color="grey10", alpha=.5) + geom_segment(x=1945, y=-17, xend=2010, yend=-17, color="grey10") + geom_segment(x=1945, y=-23, xend=2010, yend=-23, color="grey10") + geom_segment(x=1945, y=-29, xend=2010, yend=-29, color="grey10") + annotate("text", x=1941, y=-17, label="3~sigma", parse=TRUE, size=7) + annotate("text", x=1941, y=-23, label="mu[Omega]", parse=TRUE, size=7) + annotate("text", x=1941, y=-29, label="-3~sigma", parse=TRUE, size=7) + annotate("text", x=1976, y=-15, label="POLARIZATION", size=8) + theme(plot.title=element_text(size=25)) + labs(title="Spain") + scale_color_manual(values=c("grey70", "grey60","grey50", "grey40","grey30", "black"), drop=FALSE)+ scale_shape_manual(values=c(83, 68, 82, 76, 3, 67))+ scale_size_identity() Spain.fig ggsave(file=sprintf("%s%s", outpath, "ch6-f1s-CMRP_scatter_Spain.png"), width=7, height=7, dpi=600, scale=.8) ggsave(file=sprintf("%s%s", outpath, "ch6-f1s-CMRP_scatter_Spain.tiff"), width=7, height=7, dpi=600, scale=.8) #############SWEDEN #Sweden Sweden <- read.csv(file=sprintf("%s%s", inpath, "CMRP_Sweden.csv")) Sweden$partyfam <- reorder(Sweden$partyfam, Sweden$partyorder, mean, order=TRUE) Sweden$pervote <- Sweden$pervote*20 Sweden.fig <- ggplot(Sweden, aes(year, Tau_Vanilla_rel_Legacy)) + geom_point(aes(color=partyfam, size=pervote, shape=partyfam), show_guide=FALSE, alpha=.8) + theme(panel.background=element_rect(fill="white")) + labs(x = "Year", y=" Left-Right Position ") + scale_y_continuous(limits=c(-29,15), breaks=c(-15, -10, -5, 0, 5, 10, 15), labels=c("-15","-10", "-5", "0", "5", "10", "15")) + scale_x_continuous(limits=c(1941, 2010), breaks=c(1945, 1965, 1985, 2005)) + theme(axis.text.x=element_text(size=20)) + theme(axis.title.x=element_text(size=20)) + theme(axis.text.y=element_text(size=20)) + theme(axis.title.y=element_text(size=20)) + geom_ribbon(aes(ymin = Polarization_std_min, ymax=Polarization_std_max), color="grey10", alpha=.5) + geom_segment(x=1945, y=-17, xend=2010, yend=-17, color="grey10") + geom_segment(x=1945, y=-23, xend=2010, yend=-23, color="grey10") + geom_segment(x=1945, y=-29, xend=2010, yend=-29, color="grey10") + annotate("text", x=1941, y=-17, label="3~sigma", parse=TRUE, size=7) + annotate("text", x=1941, y=-23, label="mu[Omega]", parse=TRUE, size=7) + annotate("text", x=1941, y=-29, label="-3~sigma", parse=TRUE, size=7) + annotate("text", x=1976, y=-15, label="POLARIZATION", size=8) + theme(plot.title=element_text(size=25)) + labs(title="Sweden") + scale_color_manual(values=c("grey70", "grey70", "grey60","grey40","grey30", "grey20", "grey10", "black"), drop=FALSE)+ scale_shape_manual(values=c(71, 83, 68, 76, 3, 65, 80, 67))+ scale_size_identity() Sweden.fig ggsave(file=sprintf("%s%s", outpath, "ch6-f1t-CMRP_scatter_Sweden.png"), width=7, height=7, dpi=600, scale=.8) ggsave(file=sprintf("%s%s", outpath, "ch6-f1t-CMRP_scatter_Sweden.tiff"), width=7, height=7, dpi=600, scale=.8) #####Switzerland #Switzerland Switzerland <- read.csv(file=sprintf("%s%s", inpath, "CMRP_Switzerland.csv")) Switzerland$partyfam <- reorder(Switzerland$partyfam, Switzerland$partyorder, mean, order=TRUE) Switzerland$pervote <- Switzerland$pervote*20 Switzerland.fig <- ggplot(Switzerland, aes(year, Tau_Vanilla_rel_Legacy)) + geom_point(aes(color=partyfam, size=pervote, shape=partyfam), show_guide=FALSE, alpha=.8) + theme(panel.background=element_rect(fill="white")) + labs(x = "Year", y=" Left-Right Position ") + scale_y_continuous(limits=c(-29,15), breaks=c(-15, -10, -5, 0, 5, 10, 15), labels=c("-15","-10", "-5", "0", "5", "10", "15")) + scale_x_continuous(limits=c(1941, 2010), breaks=c(1945, 1965, 1985, 2005)) + theme(axis.text.x=element_text(size=20)) + theme(axis.title.x=element_text(size=20)) + theme(axis.text.y=element_text(size=20)) + theme(axis.title.y=element_text(size=20)) + geom_ribbon(aes(ymin = Polarization_std_min, ymax=Polarization_std_max), color="grey10", alpha=.5) + geom_segment(x=1945, y=-17, xend=2010, yend=-17, color="grey10") + geom_segment(x=1945, y=-23, xend=2010, yend=-23, color="grey10") + geom_segment(x=1945, y=-29, xend=2010, yend=-29, color="grey10") + annotate("text", x=1941, y=-17, label="3~sigma", parse=TRUE, size=7) + annotate("text", x=1941, y=-23, label="mu[Omega]", parse=TRUE, size=7) + annotate("text", x=1941, y=-29, label="-3~sigma", parse=TRUE, size=7) + annotate("text", x=1976, y=-15, label="POLARIZATION", size=8) + theme(plot.title=element_text(size=25)) + labs(title="Switzerland") + scale_color_manual(values=c("grey70", "grey70", "grey60","grey40","grey30", "grey20", "grey10"), drop=FALSE) + scale_shape_manual(values=c(71, 83, 68, 76, 3, 65, 80))+ scale_size_identity() Switzerland.fig ggsave(file=sprintf("%s%s", outpath, "ch6-f1u-CMRP_scatter_Switzerland.png"), width=7, height=7, dpi=600, scale=.8) ggsave(file=sprintf("%s%s", outpath, "ch6-f1u-CMRP_scatter_Switzerland.tiff"), width=7, height=7, dpi=600, scale=.8) ####United States #UnitedStates UnitedStates <- read.csv(file=sprintf("%s%s", inpath, "CMRP_UnitedStates.csv")) UnitedStates$partyfam <- reorder(UnitedStates$partyfam, UnitedStates$partyorder, mean, order=TRUE) UnitedStates$pervote <- UnitedStates$pervote*20 UnitedStates.fig <- ggplot(UnitedStates,aes(year, Tau_Vanilla_rel_Legacy)) + geom_point(aes(color=partyfam, size=pervote, shape=partyfam), show_guide=FALSE, alpha=.8) + theme(panel.background=element_rect(fill="white")) + labs(x = "Year", y=" Left-Right Position ") + scale_y_continuous(limits=c(-29,15), breaks=c(-15, -10, -5, 0, 5, 10, 15), labels=c("-15","-10", "-5", "0", "5", "10", "15")) + scale_x_continuous(limits=c(1941, 2010), breaks=c(1945, 1965, 1985, 2005)) + theme(axis.text.x=element_text(size=20)) + theme(axis.title.x=element_text(size=20)) + theme(axis.text.y=element_text(size=20)) + theme(axis.title.y=element_text(size=20)) + geom_ribbon(aes(ymin = Polarization_std_min, ymax=Polarization_std_max), color="grey10", alpha=.5) + geom_segment(x=1945, y=-17, xend=2010, yend=-17, color="grey10") + geom_segment(x=1945, y=-23, xend=2010, yend=-23, color="grey10") + geom_segment(x=1945, y=-29, xend=2010, yend=-29, color="grey10") + annotate("text", x=1941, y=-17, label="3~sigma", parse=TRUE, size=7) + annotate("text", x=1941, y=-23, label="mu[Omega]", parse=TRUE, size=7) + annotate("text", x=1941, y=-29, label="-3~sigma", parse=TRUE, size=7) + annotate("text", x=1976, y=-15, label="POLARIZATION", size=8) + theme(plot.title=element_text(size=25)) + labs(title="United States") + scale_color_manual(values=c("grey60", "black"), drop=FALSE) + scale_shape_manual(values=c(68,67))+ scale_size_identity() UnitedStates.fig ggsave(file=sprintf("%s%s", outpath, "ch6-f1v-CMRP_scatter_UnitedStates.png"), width=7, height=7, dpi=600, scale=.8) ggsave(file=sprintf("%s%s", outpath, "ch6-f1v-CMRP_scatter_UnitedStates.tiff"), width=7, height=7, dpi=600, scale=.8) #Figure 6.2 is Gephi Graph #Figure 7.1 LRK <- read.csv(file=sprintf("%s%s", inpath, "ESS_WVS_leftrightuse_2013_07_21.csv")) LRK$country.abb <- abbreviate(LRK$country) LRK.fig <- ggplot(LRK, aes(x=(reorder(country, lruse, mean, order=TRUE)))) + geom_point(aes(y=lruse_highint), shape = "+", color="black", size=5) + geom_point(aes(y=lruse_lowint), shape = "-", color="black", size=5) + geom_text(aes(y=lruse, label=abbrev), color="black") + ylab("Percentage Using Left/Right\n") + xlab(" ") + theme(legend.text= element_text(size=15)) + theme(axis.text.y = element_text(size=15, color="black")) + theme(axis.text.x = element_text(size=15, angle=90, color="black")) + theme(axis.title.x = element_text(size=15, color="black")) + theme(axis.title.y = element_text(size=15, angle=90, color="black")) + scale_y_continuous(limits = c(0,1), labels=percent_format()) + theme(panel.background=element_rect(fill="white")) LRK.fig ggsave(file=sprintf("%s%s", outpath, "ch7-f1-LRUse.png"), width=12, height=8, dpi=600) ggsave(file=sprintf("%s%s", outpath, "ch7-f1-LRUse.tiff"), width=12, height=8, dpi=600) #Figure 7.2 CSES <- read.dta(file=sprintf("%s%s", inpath, "CSES_mod23merged_1per.dta")) LRDistributions.fig <- ggplot(CSES, aes(x=LRSelf, y= LRSelf_prop)) + geom_bar(stat="identity") + geom_smooth(se=FALSE) + facet_wrap(~Polity2, ncol=5) + scale_y_continuous(breaks=c(0, .25, .5), labels=percent) + coord_cartesian(ylim=c(0,.5)) + xlab("\n Left/Right Self-Position") + ylab("\n Density") + theme(axis.text.x=element_text(size=15)) + theme(axis.text.y=element_text(size=15)) + theme(axis.title.x = element_text(size=15)) + theme(axis.title.y = element_text(size=15)) + theme(strip.text.x = element_text(size = 15)) + theme(panel.background=element_rect(fill="white")) LRDistributions.fig ggsave(file=sprintf("%s%s", outpath, "ch7-f2-CSES_LRDistributions.png"), width=10, height=10, dpi=600) ggsave(file=sprintf("%s%s", outpath, "ch7-f2-CSES_LRDistributions.tiff"), width=10, height=10, dpi=600) #Figure 7.3 Corrs <- read.csv(file=sprintf("%s%s", inpath, "CorrelatesofLR.csv")) Corrs$Environment <- rep(1,21) #variable for setting order of variables in graph Corrs$Immigration <- rep(2,21) Corrs$Conservatism <- rep(3,21) Corrs$Markets <- rep(4,21) Corrs.fig <- ggplot(Corrs) + geom_vline(xintercept=1) + geom_vline(xintercept=2) + geom_vline(xintercept=3) + geom_vline(xintercept=4) + geom_text(aes(x=Environment, y=Enviro, label=Label), size=3, position=position_jitter(width=.25))+ geom_text(aes(x=Immigration, y=Immig, label=Label), size=3,position=position_jitter(width=.25)) + geom_text(aes(x=Conservatism, y=Morals, label=Label), size=3,position=position_jitter(width=.25)) + geom_text(aes(x=Markets, y=Mark, label=Label), size=3,position=position_jitter(width=.25)) + ylab("Correlation (r)\n") + xlab(" ") + scale_x_continuous(breaks=c(1,2,3,4), labels=c("Environment", "Immigration", "Moral Conservatism", "Free Market")) + geom_hline(yintercept=0) + theme(axis.text.y = element_text(size=15)) + theme(axis.text.x = element_text(size=15, color="black")) + theme(axis.title.y = element_text(size=15)) + theme(axis.title.x = element_text(size=15)) + theme(panel.background=element_rect(fill="white")) Corrs.fig ggsave(file=sprintf("%s%s", outpath, "ch2-f3-CorrelatesOfLR.png"), width=12, height=8, dpi=600) ggsave(file=sprintf("%s%s", outpath, "ch2-f3-CorrelatesOfLR.tiff"), width=12, height=8, dpi=600) #Figure 7.4 is a Word Image Schema #Figure 7.5 %%%%%%%TAU LEGACY CSES <- read.dta(file=sprintf("%s%s",inpath,"CMRP_Original_withXYcoords_1per.dta")) CSES_Feel_LR0.fig <- ggplot(CSES, aes(x=Tau_Vanilla_rel_Legacy, y=CSES_Feel_LR0)) + geom_point(shape=1, show_guide=FALSE) + geom_smooth(color="black") + theme(axis.text.x=element_text(size=45, color="black")) + theme(axis.title.x=element_text(size=20)) + theme(axis.text.y=element_text(size=45, color="black")) + theme(axis.title.y=element_text(size=55)) + theme(plot.title=element_text(size=55)) + theme(panel.background=element_rect(fill="white")) + scale_x_continuous(limits=c(-10,10), breaks=c(-10,-5, 0, 5, 10), labels=c("L", "-5", "0", "5", "R")) + scale_y_continuous(limits=c(0,10), breaks=c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10), labels=c("-", "1", "2", "3", "4", "5", "6", "7", "8", "9", "+")) + ylab("Party Rating (Mean)\n") + xlab("") + ggtitle("Far Left (0)\n") CSES_Feel_LR0.fig ggsave(file=sprintf("%s%s",outpath,"ch7-f5a-CSES_Feel_LR0_tau.png"), width=5, height=25, dpi=600) ggsave(file=sprintf("%s%s",outpath,"ch7-f5a-CSES_Feel_LR0_tau.tiff"), width=5, height=25, dpi=600) CSES_Feel_LR1.fig <- ggplot(CSES, aes(x=Tau_Vanilla_rel_Legacy, y=CSES_Feel_LR1)) + geom_point(shape=1, show_guide=FALSE) + geom_smooth(color="black") + theme(axis.text.x=element_text(size=45, color="black")) + theme(axis.title.x=element_text(size=20)) + theme(axis.text.y=element_text(size=45, color="black")) + theme(axis.title.y=element_text(size=20)) + theme(plot.title=element_text(size=55)) + theme(legend.text=element_text(size=10)) + theme(panel.background=element_rect(fill="white")) + scale_x_continuous(limits=c(-10,10), breaks=c(-10,-5, 0, 5, 10), labels=c("L", "-5", "0", "5", "R")) + scale_y_continuous(limits=c(0,10), breaks=c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10), labels=c("-", "1", "2", "3", "4", "5", "6", "7", "8", "9", "+")) + ylab("") + xlab("") + ggtitle("Far Left (1)\n") CSES_Feel_LR1.fig ggsave(file=sprintf("%s%s",outpath,"ch7-f5b-CSES_Feel_LR1_tau.png"), width=5, height=25, dpi=600) ggsave(file=sprintf("%s%s",outpath,"ch7-f5b-CSES_Feel_LR1_tau.tiff"), width=5, height=25, dpi=600) CSES_Feel_LR2.fig <- ggplot(CSES, aes(x=Tau_Vanilla_rel_Legacy, y=CSES_Feel_LR2)) + geom_point(shape=1, show_guide=FALSE) + geom_smooth(color="black") + theme(axis.text.x=element_text(size=45, color="black")) + theme(axis.title.x=element_text(size=20)) + theme(axis.text.y=element_text(size=45, color="black")) + theme(axis.title.y=element_text(size=20)) + theme(plot.title=element_text(size=55)) + theme(legend.text=element_text(size=10)) + theme(panel.background=element_rect(fill="white")) + scale_x_continuous(limits=c(-10,10), breaks=c(-10,-5, 0, 5, 10), labels=c("L", "-5", "0", "5", "R")) + scale_y_continuous(limits=c(0,10), breaks=c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10), labels=c("-", "1", "2", "3", "4", "5", "6", "7", "8", "9", "+")) + ylab("") + xlab("") + ggtitle("Left (2)\n") CSES_Feel_LR2.fig ggsave(file=sprintf("%s%s",outpath,"ch7-f5c-CSES_Feel_LR2_tau.png"), width=5, height=25, dpi=600) ggsave(file=sprintf("%s%s",outpath,"ch7-f5c-CSES_Feel_LR2_tau.tiff"), width=5, height=25, dpi=600) CSES_Feel_LR3.fig <- ggplot(CSES, aes(x=Tau_Vanilla_rel_Legacy, y=CSES_Feel_LR3)) + geom_point(shape=1, show_guide=FALSE) + geom_smooth(color="black") + theme(axis.text.x=element_text(size=45, color="black")) + theme(axis.title.x=element_text(size=20)) + theme(axis.text.y=element_text(size=45, color="black")) + theme(axis.title.y=element_text(size=20)) + theme(plot.title=element_text(size=55)) + theme(legend.text=element_text(size=10)) + theme(panel.background=element_rect(fill="white")) + scale_x_continuous(limits=c(-10,10), breaks=c(-10,-5, 0, 5, 10), labels=c("L", "-5", "0", "5", "R")) + scale_y_continuous(limits=c(0,10), breaks=c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10), labels=c("-", "1", "2", "3", "4", "5", "6", "7", "8", "9", "+")) + ylab("") + xlab("") + ggtitle("Left (3)\n") CSES_Feel_LR3.fig ggsave(file=sprintf("%s%s",outpath,"ch7-f5d-CSES_Feel_LR3_tau.png"), width=5, height=25, dpi=600) ggsave(file=sprintf("%s%s",outpath,"ch7-f5d-CSES_Feel_LR3_tau.tiff"), width=5, height=25, dpi=600) CSES_Feel_LR4.fig <- ggplot(CSES, aes(x=Tau_Vanilla_rel_Legacy, y=CSES_Feel_LR4)) + geom_point(shape=1, show_guide=FALSE) + geom_smooth(color="black") + theme(axis.text.x=element_text(size=45, color="black")) + theme(axis.title.x=element_text(size=20)) + theme(axis.text.y=element_text(size=45, color="black")) + theme(axis.title.y=element_text(size=20)) + theme(plot.title=element_text(size=55)) + theme(legend.text=element_text(size=10)) + theme(panel.background=element_rect(fill="white")) + scale_x_continuous(limits=c(-10,10), breaks=c(-10,-5, 0, 5, 10), labels=c("L", "-5", "0", "5", "R")) + scale_y_continuous(limits=c(0,10), breaks=c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10), labels=c("-", "1", "2", "3", "4", "5", "6", "7", "8", "9", "+")) + ylab("") + xlab("") + ggtitle("Cntr-Lft (4)\n") CSES_Feel_LR4.fig ggsave(file=sprintf("%s%s",outpath,"ch7-f5e-CSES_Feel_LR4_tau.png"), width=5, height=25, dpi=600) ggsave(file=sprintf("%s%s",outpath,"ch7-f5e-CSES_Feel_LR4_tau.tiff"), width=5, height=25, dpi=600) CSES_Feel_LR5.fig <- ggplot(CSES, aes(x=Tau_Vanilla_rel_Legacy, y=CSES_Feel_LR5)) + geom_point(shape=1, show_guide=FALSE) + geom_smooth(color="black") + theme(axis.text.x=element_text(size=45, color="black")) + theme(axis.title.x=element_text(size=20)) + theme(axis.text.y=element_text(size=45, color="black")) + theme(axis.title.y=element_text(size=20)) + theme(plot.title=element_text(size=55)) + theme(legend.text=element_text(size=10)) + theme(panel.background=element_rect(fill="white")) + scale_x_continuous(limits=c(-10,10), breaks=c(-10,-5, 0, 5, 10), labels=c("L", "-5", "0", "5", "R")) + scale_y_continuous(limits=c(0,10), breaks=c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10), labels=c("-", "1", "2", "3", "4", "5", "6", "7", "8", "9", "+")) + ylab("") + xlab("") + ggtitle("Center (5)\n") CSES_Feel_LR5.fig ggsave(file=sprintf("%s%s",outpath,"ch7-f5f-CSES_Feel_LR5_tau.png"), width=5, height=25, dpi=600) ggsave(file=sprintf("%s%s",outpath,"ch7-f5f-CSES_Feel_LR5_tau.tiff"), width=5, height=25, dpi=600) CSES_Feel_LR6.fig <- ggplot(CSES, aes(x=Tau_Vanilla_rel_Legacy, y=CSES_Feel_LR6)) + geom_point(shape=1, show_guide=FALSE) + geom_smooth(color="black") + theme(axis.text.x=element_text(size=45, color="black")) + theme(axis.title.x=element_text(size=20)) + theme(axis.text.y=element_text(size=45, color="black")) + theme(axis.title.y=element_text(size=20)) + theme(plot.title=element_text(size=55)) + theme(legend.text=element_text(size=10)) + theme(panel.background=element_rect(fill="white")) + scale_x_continuous(limits=c(-10,10), breaks=c(-10,-5, 0, 5, 10), labels=c("L", "-5", "0", "5", "R")) + scale_y_continuous(limits=c(0,10), breaks=c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10), labels=c("-", "1", "2", "3", "4", "5", "6", "7", "8", "9", "+")) + ylab("") + xlab("") + ggtitle("Cntr-Rght (6)\n") CSES_Feel_LR6.fig ggsave(file=sprintf("%s%s",outpath,"ch7-f5g-CSES_Feel_LR6_tau.png"), width=5, height=25, dpi=600) ggsave(file=sprintf("%s%s",outpath,"ch7-f5g-CSES_Feel_LR6_tau.tiff"), width=5, height=25, dpi=600) CSES_Feel_LR7.fig <- ggplot(CSES, aes(x=Tau_Vanilla_rel_Legacy, y=CSES_Feel_LR7)) + geom_point(shape=1, show_guide=FALSE) + geom_smooth(color="black") + theme(axis.text.x=element_text(size=45, color="black")) + theme(axis.title.x=element_text(size=20)) + theme(axis.text.y=element_text(size=45, color="black")) + theme(axis.title.y=element_text(size=20)) + theme(plot.title=element_text(size=55)) + theme(legend.text=element_text(size=10)) + theme(panel.background=element_rect(fill="white")) + scale_x_continuous(limits=c(-10,10), breaks=c(-10,-5, 0, 5, 10), labels=c("L", "-5", "0", "5", "R")) + scale_y_continuous(limits=c(0,10), breaks=c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10), labels=c("-", "1", "2", "3", "4", "5", "6", "7", "8", "9", "+")) + ylab("") + xlab("") + ggtitle("Right (7)\n") CSES_Feel_LR7.fig ggsave(file=sprintf("%s%s",outpath,"ch7-f5h-CSES_Feel_LR7_tau.png"), width=5, height=25, dpi=600) ggsave(file=sprintf("%s%s",outpath,"ch7-f5h-CSES_Feel_LR7_tau.tiff"), width=5, height=25, dpi=600) CSES_Feel_LR8.fig <- ggplot(CSES, aes(x=Tau_Vanilla_rel_Legacy, y=CSES_Feel_LR8)) + geom_point(shape=1, show_guide=FALSE) + geom_smooth(color="black") + theme(axis.text.x=element_text(size=45, color="black")) + theme(axis.title.x=element_text(size=20)) + theme(axis.text.y=element_text(size=45, color="black")) + theme(axis.title.y=element_text(size=20)) + theme(plot.title=element_text(size=55)) + theme(legend.text=element_text(size=10)) + theme(panel.background=element_rect(fill="white")) + scale_x_continuous(limits=c(-10,10), breaks=c(-10,-5, 0, 5, 10), labels=c("L", "-5", "0", "5", "R")) + scale_y_continuous(limits=c(0,10), breaks=c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10), labels=c("-", "1", "2", "3", "4", "5", "6", "7", "8", "9", "+")) + ylab("") + xlab("") + ggtitle("Right (8)\n") CSES_Feel_LR8.fig ggsave(file=sprintf("%s%s",outpath,"ch7-f5i-CSES_Feel_LR8_tau.png"), width=5, height=25, dpi=600) ggsave(file=sprintf("%s%s",outpath,"ch7-f5i-CSES_Feel_LR8_tau.tiff"), width=5, height=25, dpi=600) CSES_Feel_LR9.fig <- ggplot(CSES, aes(x=Tau_Vanilla_rel_Legacy, y=CSES_Feel_LR9)) + geom_point(shape=1, show_guide=FALSE) + geom_smooth(color="black") + theme(axis.text.x=element_text(size=45, color="black")) + theme(axis.title.x=element_text(size=20)) + theme(axis.text.y=element_text(size=45, color="black")) + theme(axis.title.y=element_text(size=20)) + theme(plot.title=element_text(size=55)) + theme(legend.text=element_text(size=10)) + theme(panel.background=element_rect(fill="white")) + scale_x_continuous(limits=c(-10,10), breaks=c(-10,-5, 0, 5, 10), labels=c("L", "-5", "0", "5", "R")) + scale_y_continuous(limits=c(0,10), breaks=c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10), labels=c("-", "1", "2", "3", "4", "5", "6", "7", "8", "9", "+")) + ylab("") + xlab("") + ggtitle("Far Right (9)\n") CSES_Feel_LR9.fig ggsave(file=sprintf("%s%s",outpath,"ch7-f5j-CSES_Feel_LR9_tau.png"), width=5, height=25, dpi=600) ggsave(file=sprintf("%s%s",outpath,"ch7-f5j-CSES_Feel_LR9_tau.tiff"), width=5, height=25, dpi=600) CSES_Feel_LR10.fig <- ggplot(CSES, aes(x=Tau_Vanilla_rel_Legacy, y=CSES_Feel_LR10)) + geom_point(shape=1, show_guide=FALSE) + geom_smooth(color="black") + theme(axis.text.x=element_text(size=45, color="black")) + theme(axis.title.x=element_text(size=20)) + theme(axis.text.y=element_text(size=45, color="black")) + theme(axis.title.y=element_text(size=20)) + theme(plot.title=element_text(size=55)) + theme(panel.background=element_rect(fill="white")) + scale_x_continuous(limits=c(-10,10), breaks=c(-10,-5, 0, 5, 10), labels=c("L", "-5", "0", "5", "R")) + scale_y_continuous(limits=c(0,10), breaks=c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10), labels=c("-", "1", "2", "3", "4", "5", "6", "7", "8", "9", "+")) + ylab("") + xlab("") + ggtitle("Far Right (10)\n") CSES_Feel_LR10.fig ggsave(file=sprintf("%s%s",outpath,"ch7-f5k-CSES_Feel_LR10_tau.png"), width=5, height=25, dpi=600) ggsave(file=sprintf("%s%s",outpath,"ch7-f5k-CSES_Feel_LR10_tau.tiff"), width=5, height=25, dpi=600) #Figure 8.1 CDA_Polarization <- read.csv(file=sprintf("%s%s", inpath, "CMRP_Canada.csv")) Distance<- ggplot(CDA_Polarization, aes(year, Tau_Vanilla_rel_Legacy, size=pervote)) + geom_text(aes(label=label3)) + theme(panel.background=element_rect(fill="white")) + scale_x_continuous(limits=c(1945,2008),breaks=c(1945,1949,1953,1957,1958,1962,1963,1965, 1968, 1972, 1974, 1979,1980,1984,1988,1993,1997,2000,2004,2006,2008)) + scale_y_continuous(limits=c(-10, 10), breaks=c(-10, -8, -6, -4, -2, 0, 2, 4, 6, 8, 10)) + theme(axis.text.x=element_text(size=7, angle=90)) + scale_size_continuous(range=c(1, 5), limits=c(0,.55), breaks=c(.05,.15,.25,.35,.45,.55), labels=percent_format())+ guides(size=guide_legend(title="Vote Share"))+ theme(axis.title.x=element_text(size=10)) + theme(axis.text.y=element_text(size=10)) + theme(axis.text.x=element_text(size=10)) + theme(axis.title.y=element_text(size=10)) + theme(plot.title=element_text(size=10)) + theme(legend.title=element_text(size=10)) + theme(legend.text=element_text(size=10)) + ylab(" Left/Right Position\n") + xlab("\nYear") Distance ggsave(file=sprintf("%s%s",outpath,"ch8-f1-CMRP_Canada.png"), width=12, height=8, dpi=600) ggsave(file=sprintf("%s%s",outpath,"ch8-f1-CMRP_Canada.tiff"), width=12, height=8, dpi=600) #Figure 8.2 #Figure 8.2 CDA_Polarization <- read.csv(file=sprintf("%s%s", inpath, "CMRP_Canada.csv")) #Constructing the pull variable CDA_Polarization$Pull <- (CDA_Polarization$Tau_Vanilla_rel_Legacy*CDA_Polarization$pervote)/CDA_Polarization$Polarization Density <- ggplot(CDA_Polarization, aes(year, CDA_Polarization$Pull)) + geom_contour(stat="density2d", alpha=.5, color="grey", show_guide=FALSE) + geom_text(aes(label=label3, size=pervote), color="black", show_guide=FALSE) + theme(panel.background=element_rect(fill="white")) + scale_x_continuous(limits=c(1945,2008),breaks=c(1945,1949,1953,1957,1958,1962,1963,1965, 1968, 1972, 1974, 1979,1980,1984,1988,1993,1997,2000,2004,2006,2008)) + scale_y_continuous(limits=c(-.75, .75), breaks=c(-.75, -.5, -.25, 0, .25, .5, .75), labels=percent_format()) + theme(axis.text.x=element_text(size=7, angle=90)) + theme(axis.title.x=element_text(size=10)) + theme(axis.text.y=element_text(size=10)) + theme(axis.text.x=element_text(size=10)) + theme(axis.title.y=element_text(size=10)) + theme(plot.title=element_text(size=10)) + ylab("Weighted Pull\nStrong Left Strong Right\n") + xlab("Year") + geom_hline(y=0) Density ggsave(file=sprintf("%s%s",outpath,"ch8-f2-CMRP_Canada_Pull.png"), width=12, height=8, dpi=600) ggsave(file=sprintf("%s%s",outpath,"ch8-f2-CMRP_Canada_Pull.tiff"), width=12, height=8, dpi=600) #Figure 8.3 lr65 <- as.numeric(c(.0356, .0388, .0717, .4320, .1573, .1238, .1408, .0450, .0366, .0974, .4497, .1414, .1037, .1262, .1331, .1014, .1342, .4244, .0862, .0551, .0657)) pt65 <- c("pc", "lib", "ndp") pt65 <- rep(pt65, each=7) lr.x.axis7 <- c(1:7) lr.x.axis7 <- rep(lr.x.axis7, 3) #rows are pc then lib then ndp lr65_hi_int <- as.numeric(c(.0119, .0199, .0476, .2857, .2976, .2024, .1429, .0595, .0357, .1548, .3452, .1905, .1310, .0833, .2346, .3210, .1728, .1358, .0494, .0370, .0494)) lr65_mid_int <- as.numeric(c(.0370, .0406, .0716, .4248, .1683, .1372, .1205, .0388, .0364, .0905, .4653, .1445, .1152, .1093, .1121, .1016, .1438, .4327, .1003, .0515, .0580 )) lr65_low_int <- as.numeric(c(.0372, .0540, .0596, .4860, .1155, .1024, .1453, .0456, .0328, .0839, .4927, .1204, .0821, .1423, .0849, .0722, .0913, .5159, .0998, .0701, .0658 )) LeftRight65 <- data.frame(cbind(lr65, lr65_hi_int, lr65_mid_int, lr65_low_int, pt65, as.numeric(lr.x.axis7))) LeftRight65$lr65 <- as.character(LeftRight65$lr65) LeftRight65$lr65 <- as.numeric(LeftRight65$lr65) LeftRight65$pt65 <- as.character(LeftRight65$pt65) LeftRight65$lr65_hi_int <- as.numeric(as.character(LeftRight65$lr65_hi_int)) LeftRight65$lr65_mid_int <- as.numeric(as.character(LeftRight65$lr65_mid_int)) LeftRight65$lr65_low_int <- as.numeric(as.character(LeftRight65$lr65_low_int)) fig.1965.all <- ggplot(LeftRight65, aes(x=lr.x.axis7, y=lr65, group=pt65, color=pt65)) + geom_smooth(se=FALSE, guide=FALSE) + geom_text(aes(label=pt65), size=10, guide=FALSE) + theme(axis.title.y = element_text(size=30, angle=90)) + scale_y_continuous(labels=percent_format(), breaks=c(0,.25,.5), limits=c(-0.01,.55)) + scale_x_continuous(breaks=c(1,2,3,4,5,6,7), labels=c("LFT", "2", "3", "4", "5", "6", "RGT"))+ theme(axis.title.x = element_text(size=35)) + theme(axis.text.x = element_text(size=35)) + theme(axis.text.y = element_text(size=35)) + theme(legend.position= "none" ) + ggtitle(" ") + theme(panel.background=element_rect(fill="white")) + scale_colour_manual(values=c("gray60", "gray60", "gray30")) + xlab(" ") + ylab(" ") fig.1965.all ggsave(file=sprintf("%s%s", outpath, "ch8-f3a-row1col1-Canada_fig1965_all_bw.png"), width=12, height=8, dpi=600) ggsave(file=sprintf("%s%s", outpath, "ch8-f3a-row1col1-Canada_fig1965_all_bw.tiff"), width=12, height=8, dpi=600) fig.1965.hi <- ggplot(LeftRight65, aes(x=lr.x.axis7, y=lr65_hi_int, group=pt65, color=pt65)) + geom_smooth(se=FALSE, guide=FALSE) + geom_text(aes(label=pt65), size=10, guide=FALSE) + theme(axis.title.y = element_text(size=30, angle=90)) + scale_y_continuous(labels=percent_format(), breaks=c(0,.25,.5), limits=c(-0.01,.55)) + scale_x_continuous(breaks=c(1,2,3,4,5,6,7), labels=c("LFT", "2", "3", "4", "5", "6", "RGT"))+ theme(axis.title.x = element_text(size=35)) + theme(axis.text.x = element_text(size=35)) + theme(axis.text.y = element_text(size=35)) + theme(legend.position= "none" ) + ggtitle(" ") + theme(panel.background=element_rect(fill="white")) + scale_colour_manual(values=c("gray60", "gray60", "gray30")) + xlab(" ") + ylab(" ") fig.1965.hi ggsave(file=sprintf("%s%s", outpath, "ch8-f3b-row1col2-Canada_fig1965_hi_nomean_bw.png"), width=12, height=8, dpi=600) ggsave(file=sprintf("%s%s", outpath, "ch8-f3b-row1col2-Canada_fig1965_hi_nomean_bw.tiff"), width=12, height=8, dpi=600) lr79 <- as.numeric(c(.0389, .0502, .1080, .2073, .2569, .2211, .1177, .0527, .0767, .1560, .2643, .1996, .1565, .0943, .1454, .2317, .2410, .1907, .0945, .0519, .0448)) #order is con then lib then ndp lr79_high <- c(.0261, .0261, .0392, .1699, .3007, .3072, .1307, .0195, .0455, .2403, .3052, .1818, .1169, .0909, .1544, .3087, .2685, .1477, .0738, .0201, .0268) lr79_low <- c(.0506, .0712, .1266, .2294, .2421, .1820, .0981, .0607, .0732, .1464, .2741, .2103, .1558, .0794, .1549, .1972, .1989, .2377, .0968, .0634, .0511) pt79 <- c("pc", "lib", "ndp") pt79 <- rep(pt79, each=7) lr.x.axis7 <- c(1:7) lr.x.axis7 <- rep(lr.x.axis7, 3) LeftRight79 <- data.frame(cbind(lr79, pt79, as.numeric(lr.x.axis7), lr79_high, lr79_low)) LeftRight79$lr79 <- as.character(LeftRight79$lr79) LeftRight79$lr79 <- as.numeric(LeftRight79$lr79) LeftRight79$pt79 <- as.character(LeftRight79$pt79) LeftRight79$lr79_high <- as.numeric(as.character(lr79_high)) LeftRight79$lr79_low <- as.numeric(as.character(lr79_low)) fig.1979.all <- ggplot(LeftRight79, aes(x=lr.x.axis7, y=lr79, group=pt79, color=pt79)) + geom_smooth(se=FALSE, guide=FALSE) + geom_text(aes(label=pt65), size=10, guide=FALSE) + theme(axis.title.y = element_text(size=30, angle=90)) + scale_y_continuous(labels=percent_format(), breaks=c(0,.25,.5), limits=c(-0.01,.55)) + scale_x_continuous(breaks=c(1,2,3,4,5,6,7), labels=c("LFT", "2", "3", "4", "5", "6", "RGT"))+ theme(axis.title.x = element_text(size=35)) + theme(axis.text.x = element_text(size=35)) + theme(axis.text.y = element_text(size=35)) + theme(legend.position= "none" ) + ggtitle(" ") + theme(panel.background=element_rect(fill="white")) + scale_colour_manual(values=c("gray60", "gray60", "gray30")) + xlab(" ") + ylab(" ") fig.1979.all ggsave(file=sprintf("%s%s", outpath, "ch8-f3c-row2col1-Canada_fig1979_all_bw.png"), width=12, height=8, dpi=600) ggsave(file=sprintf("%s%s", outpath, "ch8-f3c-row2col1-Canada_fig1979_all_bw.tiff"), width=12, height=8, dpi=600) fig.1979.high <- ggplot(LeftRight79, aes(x=lr.x.axis7, y=lr79_high, group=pt79, color=pt79)) + geom_smooth(se=FALSE, guide=FALSE) + geom_text(aes(label=pt65), size=10, guide=FALSE) + theme(axis.title.y = element_text(size=30, angle=90)) + scale_y_continuous(labels=percent_format(), breaks=c(0,.25,.5), limits=c(-0.01,.55)) + scale_x_continuous(breaks=c(1,2,3,4,5,6,7), labels=c("LFT", "2", "3", "4", "5", "6", "RGT"))+ theme(axis.title.x = element_text(size=35)) + theme(axis.text.x = element_text(size=35)) + theme(axis.text.y = element_text(size=35)) + theme(legend.position= "none" ) + ggtitle(" ") + theme(panel.background=element_rect(fill="white")) + scale_colour_manual(values=c("gray60", "gray60", "gray30")) + xlab(" ") + ylab(" ") fig.1979.high ggsave(file=sprintf("%s%s", outpath, "ch8-f3d-row2col2-Canada_fig1979_high_nomean_bw.png"), width=12, height=8, dpi=600) ggsave(file=sprintf("%s%s", outpath, "ch8-f3d-row2col2-Canada_fig1979_high_nomean_bw.tiff"), width=12, height=8, dpi=600) lr97 <- as.numeric(c(.0194, .0254, .0433, .0679, .1403, .2381, .1791, .1351, .0821, .0291, .0403, .0180, .0225, .0457, .0495, .0855, .1754, .1799, .1769, .1507, .0562, .0397, .0828, .1011, .1870, .2169, .1487, .1234, .0490, .0421, .0238, .0077, .0176, .0772, .0525, .0787, .0694, .0718, .0826, .0517, .0826, .1289, .1235, .1813)) pt97 <- c("lib", "pc", "ndp", "ref") pt97 <- rep(pt97, each=11) lr.x.axis <- c(0:10) lr.x.axis <- rep(lr.x.axis, 4) #order is lib then pc then ndp then reform lr97_high <- c(.0214, .0171, .0235, .0556, .1688, .2286, .2009, .1517, .0791, .0235, .0299, .0107, .0150, .0235, .0278, .0641, .1603, .2115, .1795, .2030, .0641, .0406, .0651, .1302, .2126, .2343, .1518, .0954, .0369, .0390, .0174, .0065, .0108, .0394, .0284, .0503, .0547, .0547, .0481, .0263, .1007, .1575, .1882, .2516) lr97_low <- c(.0268, .0421, .0728, .0536, .1111, .2375, .1533, .1494, .0920, .0268, .0345, .0311, .0389, .0584, .0584, .0856, .2140, .1518, .1440, .1167, .0661, .0350, .0913, .0635, .1786, .1984, .1667, .1508, .0437, .0556, .0198, .0040, .0278, .0840, .0640, .0840, .0960, .08, .1080, .0760, .0560, .1040, .1200, .1280) LeftRight97 <- data.frame(cbind(lr97, pt97, as.numeric(lr.x.axis), lr97_high, lr97_low)) LeftRight97$lr97 <- as.character(LeftRight97$lr97) LeftRight97$lr97 <- as.numeric(LeftRight97$lr97) LeftRight97$pt97 <- as.character(LeftRight97$pt97) LeftRight97$lr97_high <- as.numeric(as.character(lr97_high)) LeftRight97$lr97_low <- as.numeric(as.character(lr97_low)) fig.1997.all <- ggplot(LeftRight97, aes(x=lr.x.axis, y=lr97, group=pt97, color=pt97)) + geom_smooth(se=FALSE, guide=FALSE) + geom_text(aes(label=pt97), size=10, guide=FALSE) + theme(axis.title.y = element_text(size=30, angle=90)) + scale_y_continuous(labels=percent_format(), breaks=c(0,.17,.35), limits=c(0,.35)) + scale_x_continuous(breaks=c(0,1,2,3,4,5,6,7,8,9,10), labels=c("LFT", "1", "2", "3", "4", "5", "6", "7", "8", "9", "RGT"))+ theme(axis.title.x = element_text(size=35)) + theme(axis.text.x = element_text(size=35)) + theme(axis.text.y = element_text(size=35)) + theme(legend.position= "none" ) + ggtitle(" ") + theme(panel.background=element_rect(fill="white")) + scale_colour_manual(values=c("gray60", "gray60", "gray30", "black")) + xlab(" ") + ylab(" ") fig.1997.all ggsave(file=sprintf("%s%s", outpath, "ch8-f3e-row3col1-Canada_fig1997_all_bw.png"), width=12, height=8, dpi=600) ggsave(file=sprintf("%s%s", outpath, "ch8-f3e-row3col1-Canada_fig1997_all_bw.tiff"), width=12, height=8, dpi=600) fig.1997.high <- ggplot(LeftRight97, aes(x=lr.x.axis, y=lr97_high, group=pt97, color=pt97)) + geom_smooth(se=FALSE, guide=FALSE) + geom_text(aes(label=pt97), size=10, guide=FALSE) + theme(axis.title.y = element_text(size=30, angle=90)) + scale_y_continuous(labels=percent_format(), breaks=c(0,.17,.35), limits=c(0,.35)) + scale_x_continuous(breaks=c(0,1,2,3,4,5,6,7,8,9,10), labels=c("LFT", "1", "2", "3", "4", "5", "6", "7", "8", "9", "RGT"))+ theme(axis.title.x = element_text(size=35)) + theme(axis.text.x = element_text(size=35)) + theme(axis.text.y = element_text(size=35)) + theme(legend.position= "none" ) + ggtitle(" ") + theme(panel.background=element_rect(fill="white")) + scale_colour_manual(values=c("gray60", "gray60", "gray30", "black")) + xlab(" ") + ylab(" ") fig.1997.high ggsave(file=sprintf("%s%s", outpath, "ch8-f3f-row3col2-Canada_fig1997_high_nomean_bw.png"), width=12, height=8, dpi=600) ggsave(file=sprintf("%s%s", outpath, "ch8-f3f-row3col2-Canada_fig1997_high_nomean_bw.tiff"), width=12, height=8, dpi=600) lr11 <- as.numeric(c(.0264, .0206, .0250, .0323, .0308, .0866, .0734, .1564, .2122, .1483, .1880, .0274, .0230, .0534, .0956, .1475, .2639, .1809, .1053, .0719, .0178, .0133, .0712, .0912, .1810, .2070, .1795, .1484, .0475, .0282, .0208, .0119, .0134)) #row structure con then lib then ndp lr11.highint <- c(.0156, .0097, .0117, .0214, .0136, .0507, .0643, .1423, .2612, .1871, .2222, .0118, .0117, .0492, .0945, .1791, .2677, .1909, .1063, .0650, .0059, .0180, .0630, .1083, .2087, .2421, .2041, .0945, .0295, .0157, .0138, .0059, .0138) lr11.lowint <- c(.0547, .0328, .0328, .0438, .0365, .1460, .0803, .1606, .1460, .0985, .1679, .0404, .0257, .0588, .1029, .1250, .2647, .1434, .1287, .0625, .0257, .0221, .0699, .0699, .1618, .1912, .1360, .2353, .0478, .0404, .0184, .0147, .0147) pt11 <- c("con", "lib", "ndp") pt11 <- rep(pt11, each=11) lr.x.axis11 <- c(0:10) lr.x.axis11 <- rep(lr.x.axis11, 3) LeftRight11 <- data.frame(cbind(lr11, pt11, as.numeric(lr.x.axis11), lr11.highint, lr11.lowint)) LeftRight11$lr11 <- as.character(LeftRight11$lr11) LeftRight11$lr11 <- as.numeric(LeftRight11$lr11) LeftRight11$pt11 <- as.character(LeftRight11$pt11) LeftRight11$lr11.highint <- as.numeric(as.character(LeftRight11$lr11.highint)) LeftRight11$lr11.lowint <- as.numeric(as.character(LeftRight11$lr11.lowint)) fig.2011.all <- ggplot(LeftRight11, aes(x=lr.x.axis11, y=lr11, group=pt11, color=pt11)) + geom_smooth(se=FALSE, guide=FALSE) + geom_text(aes(label=pt11), size=10, guide=FALSE) + theme(axis.title.y = element_text(size=30, angle=90)) + scale_y_continuous(labels=percent_format(), breaks=c(0,.17,.35), limits=c(0,.35)) + scale_x_continuous(breaks=c(0,1,2,3,4,5,6,7,8,9,10), labels=c("LFT", "1", "2", "3", "4", "5", "6", "7", "8", "9", "RGT"))+ theme(axis.title.x = element_text(size=35)) + theme(axis.text.x = element_text(size=35)) + theme(axis.text.y = element_text(size=35)) + theme(legend.position= "none" ) + ggtitle(" ") + theme(panel.background=element_rect(fill="white")) + scale_colour_manual(values=c("black", "gray60", "gray60")) + xlab(" ") + ylab(" ") fig.2011.all fig.2011.all ggsave(file=sprintf("%s%s", outpath, "ch8-f3g-row4col1-Canada_fig2011_all_bw.png"), width=12, height=8, dpi=600) ggsave(file=sprintf("%s%s", outpath, "ch8-f3g-row4col1-Canada_fig2011_all_bw.tiff"), width=12, height=8, dpi=600) fig.2011.high <- ggplot(LeftRight11, aes(x=lr.x.axis11, y=lr11.highint, group=pt11, color=pt11)) + geom_smooth(se=FALSE, guide=FALSE) + geom_text(aes(label=pt11), size=10, guide=FALSE) + theme(axis.title.y = element_text(size=30, angle=90)) + scale_y_continuous(labels=percent_format(), breaks=c(0,.17,.35), limits=c(0,.35)) + scale_x_continuous(breaks=c(0,1,2,3,4,5,6,7,8,9,10), labels=c("LFT", "1", "2", "3", "4", "5", "6", "7", "8", "9", "RGT"))+ theme(axis.title.x = element_text(size=35)) + theme(axis.text.x = element_text(size=35)) + theme(axis.text.y = element_text(size=35)) + theme(legend.position= "none" ) + ggtitle(" ") + theme(panel.background=element_rect(fill="white")) + scale_colour_manual(values=c("black", "gray60", "gray60")) + xlab(" ") + ylab(" ") fig.2011.high fig.2011.high ggsave(file=sprintf("%s%s", outpath, "ch8-f3h-row4col2-Canada_fig2011_hi_nomean_bw.png"), width=12, height=8, dpi=600) ggsave(file=sprintf("%s%s", outpath, "ch8-f3h-row4col2-Canada_fig2011_hi_nomean_bw.tiff"), width=12, height=8, dpi=600) #Figure 8.4 - Data only. Original Syntax Lost from Dropbox [TO RECOVER] pid <- c("2.Liberal PID", "3.PC/Conservative PID", "1.NDP PID", "4.Reform/Alliance PID") pid <- rep(pid, 12) year <- c(1968, 1974, 1979, 1980, 1988, 1993, 1997, 2000, 2004, 2006, 2008, 2011) year <- rep(year, each=4) Lib.Label <- c("lib") Lib.Label <- rep(Lib.Label, 48) Con.Label <- c("con") PC.Label <- c("pc") Con.Label <- c(rep(PC.Label, 32), rep(Con.Label,16)) NDP.Label <- c("ndp") NDP.Label <- rep(NDP.Label, 48) Ref.Label <- c("ref") Ref.Label <- rep(Ref.Label, 48) #format in rows: LIB, PC, NDP, Reform/Alliance (1968, 1974, 1979, 1980, 1988, 1993,1997, 2000, 2004, 2006, 2008, 2011) lib_rating <- c(79.2, 49.7, 51.5, NA, 79.1, 44.6, 46.1, NA, 76.0, 40.6, 46.1, NA, 75.5, 38.3, 44.8, NA, 65.7, 43.8, 47, NA, 74.9, 57.2, 60.4, 53.2, 71.2, 46.1, 46.2, 36.6, 74.6, 45.2, 48.4, 32.6, 67.5, 34.1, 40.3, NA, 69.1, 26.5, 44, NA, 68.6, 39.3, 44.3, NA, 66.8, 31.2, 44.5, NA) lib_rating_se <- c(.4275, .9429, 1.411, NA, .6092, 1.461, 2.104, NA, .540, .893, 1.336, NA, .578, 1.01, 1.501, NA, .7501, .6964, 1.240, NA, .593, .835, 1.311, 1.689, .654, 1.144, 1.633, 1.517, .690, 1.72, 2.08, 1.372, .680, .892, 1.4, NA, .643, .827, 1.182, NA, .816, .924, 1.539, NA, .705, .749, 1.212, NA) lib_min <- lib_rating - 1.96*lib_rating_se lib_max <- lib_rating + 1.96*lib_rating_se con_rating <- c(49.7, 73.9, 49.5, NA, 45.8, 75.9, 42.5, NA, 45.3, 77.1, 45.0, NA, 41.6, 73.9, 38.8, NA, 50.1, 71.3, 39.4, NA, 36.0, 53.6, 32.8, 31.0, 44.3, 65.2, 31.1, 36.0, 40.8, 70.9, 35.3, 40.8, 41.4, 70.7, 28.5, NA, 36.1, 73.3, 30.5, NA, 42.1, 77.2, 32.6, NA, 36.3, 75.7, 29.3, NA) con_rating_se <- c(.593, .753, 1.196, NA, .883, 1.035, 2.32, NA, .679, .567, 1.306, NA, .705, .705, 1.567, NA, .898, .626, 1.290, NA, .8303, .973, 1.637, 1.690, .841, 1.037, 1.433, 1.483, .878, 1.377, 1.819, 1.282, .788, .705, 1.467, NA, .814, .676, 1.298, NA, 1.095, .668, 1.614, NA, .910, .608, 1.283, NA) con_min <- con_rating - 1.96*con_rating_se con_max <- con_rating + 1.96*con_rating_se ndp_rating <- c(43.6, 43.7, 80.8, NA, 40.7, 39, 77.5, NA, 44.1, 39.4, 79.4, NA, 43.7, 34.3, 77.7, NA, 42.1, 35.3, 70.2, NA, 39.7, 32.3, 60.5, 27.8, 35.8, 29.0, 69.1, 25.1, 37.8, 41.3, 72.5, 26.5, 41.8, 31.6, 72.5, NA, 44.2, 33.7, 74.5, NA, 49.8, 36.8, 76.4, NA, 50.2, 34.4, 76.7, NA) ndp_rating_se <- c(.735, 1.065, 1.012, NA, 1.034, 1.514, 1.639, NA, .759, .957, .866, NA, .851, 1.081, 1.045, NA, .871, .818, 1.132, NA, .784, .887, 1.399, 1.51, .843, 1.135, 1.355, 1.421, .887, 1.609, 1.808, 1.260, .814, .917, 1.113, NA, .791, .831, .854, NA, .928, .976, 1.158, NA, .789, .789, .932, 1.31) ndp_min <- ndp_rating - 1.96*ndp_rating_se ndp_max <- ndp_rating + 1.96*ndp_rating_se ref_rating <- c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 39.4, 49.8, 38.5, 72.7, 27.8, 37.8, 21.3, 75.4, 32.9, 41.9, 22.1, 78.4, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA) ref_rating_se <- c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, .928, 1.066, 1.838, 1.279, .862, 1.281, 1.475, 1.131, .921, 1.99, 1.94, .906, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA) ref_max = ref_rating + 1.96*ref_rating_se ref_min = ref_rating - 1.96*ref_rating_se PartyRatings <- data.frame(cbind(pid, lib_rating, lib_min, lib_max, con_rating, con_min, con_max, ndp_rating, ndp_min, ndp_max, ref_rating, ref_min, ref_max, pid, year, Lib.Label, Con.Label, NDP.Label, Ref.Label)) PartyRatings$lib_rating <- as.numeric(as.character(lib_rating)) PartyRatings$con_rating <- as.numeric(as.character(con_rating)) PartyRatings$ndp_rating <- as.numeric(as.character(ndp_rating)) PartyRatings$ref_rating <- as.numeric(as.character(ref_rating)) PartyRatings$lib_min<- as.numeric(as.character(lib_min)) PartyRatings$lib_max<- as.numeric(as.character(lib_max)) PartyRatings$con_min<- as.numeric(as.character(con_min)) PartyRatings$con_max<- as.numeric(as.character(con_max)) PartyRatings$ndp_min<- as.numeric(as.character(ndp_min)) PartyRatings$ndp_max<- as.numeric(as.character(ndp_max)) PartyRatings$ref_min<- as.numeric(as.character(ref_min)) PartyRatings$ref_max<- as.numeric(as.character(ref_max)) Canada_Ratings <- ggplot(PartyRatings, aes(x=year)) + geom_text(aes(y=lib_rating, label=Lib.Label), color="Red") + geom_errorbar(aes(ymin=lib_min, ymax=lib_max), width=.1, color="Red", alpha=.5) + geom_smooth(aes(y=lib_rating, group=pid), color="Red", se=FALSE, guide=FALSE) + geom_text(aes(y=con_rating, label=Con.Label), color="Blue") + geom_errorbar(aes(ymin=con_min, ymax=con_max), width=.1, color="Blue", alpha=.5) + geom_smooth(aes(y=con_rating, group=pid), color="Blue", guide=FALSE, se=FALSE) + geom_text(aes(y=ndp_rating, label=NDP.Label), color="#FF6600") + geom_smooth(aes(y=ndp_rating, group=pid), color="#FF6600", se=FALSE, guide=FALSE) + geom_errorbar(aes(ymin=ndp_min, ymax=ndp_max), width=.1, color="#FF6600", alpha=.5) + geom_text(aes(y=ref_rating, label=Ref.Label), color="Dark Green") + geom_smooth(aes(y=ref_rating, group=pid), color="Dark Green", se=FALSE, guide=FALSE) + geom_errorbar(aes(ymin=ref_min, ymax=ref_max), width=.1, color="Dark Green", alpha=.5) + opts(axis.title.y = theme_text(size=15, angle=90)) + opts(axis.title.x = theme_text(size=15)) + opts(axis.text.x = theme_text(size=15, angle=90)) + opts(axis.text.y = theme_text(size=15)) + scale_y_continuous(breaks=c(20, 30, 40, 50, 60, 70, 80))+ facet_grid(~pid) + ylab("- Thermometer Rating + \n") + xlab("\nYear") + opts(panel.background=theme_rect(fill="white", color="black")) + opts(strip.text.x = theme_text(size = 15)) + opts(strip.background = theme_rect(fill="white", color="black")) Canada_Ratings ggsave(file="/Users/chriscochrane/Dropbox/Projects/Book/Graphs/Canada_Ratings.pdf", width=14, height=8) #Figure 8.5 - Data Only Original Syntax Lost from Dropbox