Browse Source

Graph collection

Petra Lamborn 3 years ago
parent
commit
5befb32a28
1 changed files with 15 additions and 15 deletions
  1. 15
    15
      votingpatterns.R

+ 15
- 15
votingpatterns.R View File

@@ -78,31 +78,31 @@ advplot <- ggplot(vtypes, aes(x = Year, y = Votes, fill = Type)) + geom_area() +
78 78
 advplot
79 79
 
80 80
 propplot <- ggplot(filter(partylev, Party %in% names(partycolours)),
81
-       aes(x = Year, y = Advance_Proportion, colour = Party)) + geom_line() +
81
+       aes(x = Year, y = Advance_Proportion, colour = Party)) + geom_line() + geom_point() +
82 82
     scale_colour_manual(values = partycolours) +
83 83
     scale_y_continuous("Percent of votes from Advance votes",
84 84
                        labels = scales::percent, limits=c(0, NA), expand=c(0,0)) +
85 85
     scale_x_continuous("General Election Year",
86
-                       breaks = e.years,
87
-                       expand = c(0,0)) +
86
+                       breaks = e.years) +
88 87
     labs(title = "Share of Each Party's Votes From Advanced Votes by Year")
89 88
 propplot
90 89
 
91 90
 
92
-ggplot(filter(partylev, Party %in% names(partycolours)),
91
+scplot <- ggplot(filter(partylev, Party %in% names(partycolours)),
93 92
        aes(x = Year, y = Seat_Difference, colour = Party)) +
94
-    geom_line() +
93
+    geom_line() + geom_point() + 
95 94
     scale_colour_manual(values = partycolours) +
96 95
     scale_x_continuous("General Election Year",
97
-                       breaks = e.years, expand = c(0,0)) +
98
-    labs(title = )
99
-
100
-svp <- partylev %>% mutate(PV_Prop_Difference = PV_Prop_Total - PV_Prop_Advance) %>%
101
-    select(Year, Party, Seat_Difference, PV_Prop_Difference) %>%
102
-    filter(Party %in% names(partycolours))
96
+                       breaks = e.years) +
97
+    scale_y_continuous("Seat change from advance results and final results", n.breaks = 8,
98
+                       labels = function(x) { paste0(ifelse(x > 0, "+", ""), x) }) +
99
+    labs(title = "Seat Change Between Advance Vote Results and Final Results")
100
+scplot
103 101
 
104
-ggplot(svp, aes(PV_Prop_Difference, Seat_Difference, colour = Party)) + geom_point() +
102
+pvplot <- ggplot(filter(partylev, Party %in% names(partycolours)),
103
+       aes(x = Year, y = PV_Prop_Total, colour = Party)) +
104
+    geom_line() + geom_point() +
105 105
     scale_colour_manual(values = partycolours) +
106
-    scale_x_continuous("Party Vote Proportion Difference", labels = scales::percent) +
107
-    labs(title = "Relationship between vote difference and seat difference",
108
-         y = "Seat Difference")
106
+    scale_y_continuous("Party vote proportion", n.breaks = 10,
107
+                       expand=c(0,0), limits = c(0, 0.5), labels = scales::percent)
108
+pvplot