File:RotherhamGraph.svg
Summary
| Description |
English: United Kingdom general election results for Rotherham constituency. |
| Date | |
| Source | Own work |
| Author | JeremyA |
| SVG development | Category:Invalid SVG created with R#1000RotherhamGraph.svg |
Notes
The Background colour indicates the party of the sitting MP at any given year.
Elections held in 1895 and 1906 do not appear on this graph. Only one candidate (Liberal) stood at each of these elections and so no votes were cast, the candidate being elected unopposed.
Graph drawn with R.
Statistics gathered from:
- http://www.psr.keele.ac.uk/area/uk/edates.htm archive copy at the Wayback Machine
- http://news.bbc.co.uk/hi/english/static/vote2001/results_constituencies/constituencies/512.stm
- http://news.bbc.co.uk/1/shared/vote2005/html/512.stm
Parties:
- Conservative = Conservative Party (1885–1918; 1964–present); Conservative and Liberal Unionist (1922–1959).
- Labour = Labour Party
- Liberal = Liberal Party (1885–1979); SDP-Liberal Alliance (1983–1987); Liberal Democrats (1992–present).
- UKIP = UK Independence Party
Data Used:
| Year | Conservative | Labour | Liberal | UKIP | Other |
|---|---|---|---|---|---|
| 1885.96 | 26.4 | 73.6 | |||
| 1886.57 | 28.7 | 71.3 | |||
| 1892.57 | 30.2 | 69.8 | |||
| 1895.6 | |||||
| 1899 | 41.4 | 58.6 | |||
| 1900.81 | 42 | 58 | |||
| 1906.11 | |||||
| 1910.11 | 27.6 | 72.4 | |||
| 1910.97 | 32.5 | 67.5 | |||
| 1918.95 | 44.8 | 38.1 | 14.9 | 2.2 | |
| 1922.87 | 51 | 49 | |||
| 1923.93 | 46.1 | 53.9 | |||
| 1924.8 | 45.4 | 54.6 | |||
| 1929.41 | 22.7 | 60.4 | 16.9 | ||
| 1931.82 | 50.8 | 49.2 | |||
| 1933 | 30.9 | 69.1 | |||
| 1935.87 | 67.5 | 32.5 | |||
| 1945.51 | 74.2 | 25.8 | |||
| 1950.148 | 30.5 | 64.4 | 5.1 | ||
| 1951.9 | 34.39 | 65.61 | |||
| 1955.5 | 36.67 | 63.33 | |||
| 1959.83 | 37.2 | 62.8 | |||
| 1964.83 | 33.52 | 66.48 | |||
| 1966.33 | 30.32 | 69.68 | |||
| 1970.5 | 33.59 | 66.41 | |||
| 1974.25 | 22.92 | 59.97 | 17.11 | ||
| 1974.86 | 22.06 | 64.58 | 13.35 | ||
| 1979.42 | 29.94 | 60.55 | 8.4 | 1.12 | |
| 1983.5 | 25.7 | 54.29 | 20 | ||
| 1987.5 | 22.09 | 59.68 | 18.23 | ||
| 1992.33 | 23.75 | 63.95 | 12.31 | ||
| 1997.42 | 14.3 | 71.32 | 10.41 | 3.98 | |
| 2001.5 | 19.4 | 63.9 | 10.6 | 2.5 | 3.7 |
| 2005.42 | 16.6 | 52.8 | 17.2 | 3.7 | 9.6 |
| 2010.35 | 16.7 | 44.6 | 16 | 5.9 | 16.7 |
| 2012.91 | 5.42 | 46.25 | 2.11 | 21.8 | 24.3 |
| 2015.35 | 12.3 | 52.5 | 2.9 | 30.2 | 2.1 |
| 2017.44 | 26.4 | 56.4 | 4.6 | 8.7 | 3.8 |
Source code

This media was created with R (programming language for statistical analysis)Category:Images with R source code
Here is a listing of the source used to create this file.
Here is a listing of the source used to create this file.
The graph was produced with R. The following 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:RotherhamGraph.svg")
ggsave("RotherhamGraph.svg", device = "svg", units = "cm", width = 20, height = 11, dpi = 120)
Licensing
I, the copyright holder of this work, hereby publish it under the following license:
This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
- 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.