File:DonValleyGraph.svg
![File:DonValleyGraph.svg](https://upload.wikimedia.org/wikipedia/commons/thumb/2/24/DonValleyGraph.svg/512px-DonValleyGraph.svg.png?20170615143102)
Original file (SVG file, nominally 512 × 282 pixels, file size: 34 KB)
Captions
Captions
Summary
[edit]DescriptionDonValleyGraph.svg |
English: United Kingdom general election results for Don Valley constituency from its creation in 1918 to 2017. |
Date | |
Source | Own work |
Author | JeremyA |
Notes
[edit]The Background colour indicates the party of the sitting MP at any given year. From 1918 to 1922 the seat was held by the National Democratic Party
Graph drawn with R
Statistics gathered from:
Parties:
- Conservative = Conservative Party
- Labour = Labour Party
- Liberal = Liberal Party (1918–1979); SDP-Liberal Alliance (1983–1987); Liberal Democrats (1992–present).
Data used:
Year | Conservative | Labour | Liberal | UKIP | Other |
---|---|---|---|---|---|
1918.95 | 24.5 | 29.3 | 46.2 | ||
1922.87 | 47 | 25.4 | 27.6 | ||
1923.93 | 39.6 | 60.4 | |||
1924.8 | 46.1 | 53.9 | |||
1929.41 | 26.7 | 73.3 | |||
1931.82 | 41.4 | 58.6 | |||
1935.87 | 31.1 | 68.9 | |||
1945.51 | 28.3 | 71.1 | |||
1950.148 | 24.6 | 75.4 | |||
1951.9 | 25.9 | 74.1 | |||
1955.5 | 26.3 | 73.7 | |||
1959.83 | 29.1 | 70.9 | |||
1964.83 | 28.1 | 71.9 | |||
1966.33 | 25.1 | 74.9 | |||
1970.5 | 30.5 | 69.5 | |||
1974.25 | 29.9 | 70.1 | |||
1974.86 | 21.2 | 63.3 | 15.6 | ||
1979.42 | 31.2 | 55.6 | 11.6 | 1.6 | |
1983.5 | 32.4 | 45.1 | 22.5 | ||
1987.5 | 32.3 | 53.1 | 11.9 | ||
1992.33 | 31.7 | 55 | 11.9 | 1.4 | |
1997.42 | 24.6 | 58.3 | 9.7 | 7.5 | |
2001.5 | 28.6 | 54.6 | 11.2 | 2.1 | 3.5 |
2005.42 | 29.4 | 52.7 | 18 | ||
2010.35 | 29.7 | 37.9 | 17.1 | 4.4 | 10.9 |
2015.35 | 25.3 | 46.2 | 3.5 | 23.5 | 1.6 |
2017.44 | 41.7 | 53 | 1.9 | 3.5 |
Code:
The following R code will reproduce the graph using the data on this page.
library(tidyverse)
library(htmltab)
election_graph <- function(pageURL) {
election <- htmltab(pageURL,
which = 2,
rm_nodata_cols = F)
election <- as.tibble(lapply(election, function(x) {gsub("unopp", "100", x)}))
tidy_election <- gather(election, "Party", "Votes", 2:length(election))
tidy_election$Year <- as.numeric(tidy_election$Year)
tidy_election$Party <- factor(tidy_election$Party, levels = c("Conservative", "Labour", "Liberal", "Green", "SNP", "UKIP", "Other"))
tidy_election$Votes <- as.numeric(tidy_election$Votes)
election_victor <- tidy_election %>% filter(is.na(Votes) == FALSE) %>% group_by(Year) %>% summarize(Party = Party[which(Votes == max(Votes))])
election_victor$Year <- as.numeric(election_victor$Year)
election_victor$start_year <- election_victor$Year
election_victor$end_year <- c(election_victor$Year[-1], ceiling(election_victor$Year[length(election_victor$Year)] + 1))
election_victor[1,3] <- floor(election_victor[1,3] - 1)
tidy_election$Votes <- as.numeric(sapply(tidy_election$Votes, function(x) {gsub(100, NA, x)}))
party_colours <- c("#0087DC", "#DC241F", "#FAA61A", "#008066", "#FFF95D", "#EFE600", "dark grey")
names(party_colours) <- c("Conservative", "Labour", "Liberal", "Green", "SNP", "UKIP", "Other")
ggplot(tidy_election) +
geom_rect(data = election_victor,
aes(xmin = start_year,xmax = end_year, ymin = -Inf, ymax = Inf, fill = Party),
alpha = 0.35,
show.legend = F) +
geom_line(aes(x = Year, y = Votes, colour = Party), size = 0.703) +
geom_point(aes(x = Year, y = Votes, colour = Party)) +
geom_hline(yintercept = 100, color="black", size = 1.5) +
geom_vline(xintercept = 2019, color="black", size = 1.5) +
scale_colour_manual(values = party_colours) +
scale_fill_manual(values = party_colours) +
theme(text = element_text(color="black", size = 14),
axis.text = element_text(color="black", size = 11),
axis.line.x = element_line(color="black", size = 0.703),
axis.ticks.x = element_line(color="black", size = 0.703),
axis.line.y = element_line(color="black", size = 0.703),
axis.ticks.y = element_line(color="black", size = 0.703),
axis.ticks.length = unit(5, "points"),
panel.grid.major = element_line(color="blue", size = 0.5, linetype = 3),
panel.grid.minor = element_blank(),
panel.background = element_blank(),
legend.position = c(.98, .97),
legend.direction = "horizontal",
legend.text = element_text(color="black", size = 11),
legend.title=element_blank(),
legend.justification = c("right", "top"),
legend.box.just = "right",
legend.key = element_blank(),
legend.background = element_rect(fill = "white", colour = "black"),
legend.margin = margin(0, 4, 4, 4)) +
scale_x_continuous(expand = c(0, 0), limits = c(election_victor[[1,3]], election_victor$end_year[length(election_victor$end_year)]), breaks = seq(1890, 2010, 10)) +
scale_y_continuous(expand = c(0, 0), limits = c(0, 100), breaks = seq(0, 100, 20)) +
labs(x = "Year", y = "Percentage Vote")
}
election_graph("https://commons.wikimedia.org/wiki/File:DonValleyGraph.svg")
ggsave("DonValleyGraph.svg", device = "svg", units = "cm", width = 20, height = 11, dpi = 120)
Licensing
[edit]![w:en:Creative Commons](https://upload.wikimedia.org/wikipedia/commons/thumb/7/79/CC_some_rights_reserved.svg/90px-CC_some_rights_reserved.svg.png)
![attribution](https://upload.wikimedia.org/wikipedia/commons/thumb/1/11/Cc-by_new_white.svg/24px-Cc-by_new_white.svg.png)
![share alike](https://upload.wikimedia.org/wikipedia/commons/thumb/d/df/Cc-sa_white.svg/24px-Cc-sa_white.svg.png)
- You are free:
- to share – to copy, distribute and transmit the work
- to remix – to adapt the work
- Under the following conditions:
- attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
- share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.
File history
Click on a date/time to view the file as it appeared at that time.
Date/Time | Thumbnail | Dimensions | User | Comment | |
---|---|---|---|---|---|
current | 14:31, 15 June 2017 | ![]() | 512 × 282 (34 KB) | JeremyA (talk | contribs) | User created page with UploadWizard |
You cannot overwrite this file.
File usage on Commons
The following page uses this file:
File usage on other wikis
The following other wikis use this file:
- Usage on en.wikipedia.org
Metadata
This file contains additional information such as Exif metadata which may have been added by the digital camera, scanner, or software program used to create or digitize it. If the file has been modified from its original state, some details such as the timestamp may not fully reflect those of the original file. The timestamp is only as accurate as the clock in the camera, and it may be completely wrong.
Width | 100% |
---|---|
Height | 100% |