Size of this PNG preview of this SVG file: 800 × 441 pixels. Other resolutions: 320 × 176 pixels | 640 × 353 pixels | 1,024 × 564 pixels | 1,280 × 705 pixels | 2,560 × 1,410 pixels | 944 × 520 pixels.
Original file (SVG file, nominally 944 × 520 pixels, file size: 85 KB)
This is a file from the Wikimedia Commons. Information from its description page there is shown below. Commons is a freely licensed media file repository. You can help. |
Summary
DescriptionLivingstonGraph.svg |
English: United Kingdom general election results for Livingston constituency from its creation in 1983 to 2017. |
Date | |
Source | Own work |
Author | JeremyA |
Notes
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/380.stm
- http://news.bbc.co.uk/1/shared/vote2005/html/715.stm
Parties:
- Conservative = Conservative Party (UK)
- Labour = Labour Party (UK)
- Liberal = SDP-Liberal Alliance (1983–1987); Liberal Democrats (UK) (1992–present).
- SNP = Scottish National Party
Graph drawn with R
Source Data:
Year | Conservative | Labour | Liberal | SNP | Other |
---|---|---|---|---|---|
1983.5 | 24.2 | 37.7 | 24.6 | 13.5 | |
1987.5 | 18.7 | 45.6 | 19.1 | 16.6 | |
1992.33 | 19.4 | 44.4 | 8.6 | 26.6 | 1 |
1997.42 | 9.4 | 54.9 | 6.7 | 27.5 | 1.5 |
2001.5 | 8.3 | 53 | 11 | 23.6 | 4.1 |
2005.42 | 10.1 | 51.1 | 15.4 | 21.6 | 1.8 |
2005.74 | 6.8 | 41.8 | 14.8 | 32.7 | 4 |
2010.35 | 10.8 | 48.5 | 11.1 | 25.9 | 3.7 |
2015.35 | 10.3 | 27.6 | 2.1 | 56.9 | 3.1 |
2017.44 | 24.4 | 32.7 | 2.9 | 40.1 | |
2019.95 | 22.3 | 21.8 | 6.3 | 46.9 | 2.6 |
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 = 2021, 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:LivingstonGraph.svg")
ggsave("LivingstonGraph.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.
Items portrayed in this file
depicts
15 June 2017
File history
Click on a date/time to view the file as it appeared at that time.
Date/Time | Thumbnail | Dimensions | User | Comment | |
---|---|---|---|---|---|
current | 18:30, 31 May 2024 | 944 × 520 (85 KB) | JeremyA | +2019 | |
18:20, 31 May 2024 | 512 × 282 (21 KB) | JeremyA | Reverted to version as of 14:42, 15 June 2017 (UTC) SVG issue | ||
18:19, 31 May 2024 | 756 × 416 (16 KB) | JeremyA | +2019 | ||
14:42, 15 June 2017 | 512 × 282 (21 KB) | JeremyA | User created page with UploadWizard |
File usage
The following 2 pages use this file:
Metadata
This file contains additional information, probably added from the digital camera or scanner used to create or digitize it.
If the file has been modified from its original state, some details may not fully reflect the modified file.
Width | 708pt |
---|---|
Height | 390pt |
Retrieved from "https://en.wiki.x.io/wiki/File:LivingstonGraph.svg"