File:QC polling 42nd election.svg
![File:QC polling 42nd election.svg](https://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/QC_polling_42nd_election.svg/800px-QC_polling_42nd_election.svg.png?20161020214514)
Size of this PNG preview of this SVG file: 800 × 533 pixels. Other resolutions: 320 × 213 pixels | 640 × 427 pixels | 1,024 × 683 pixels | 1,280 × 853 pixels | 2,560 × 1,707 pixels | 810 × 540 pixels.
Original file (SVG file, nominally 810 × 540 pixels, file size: 248 KB)
File information
Structured data
Captions
Captions
Add a one-line explanation of what this file represents
Summary
editDescriptionQC polling 42nd election.svg |
English: A combination of opinion polls for the 42nd Quebec general election. The trend lines are local regressions with α = 0.45 and 95% confidence interval ribbons. Election results are represented by diamonds. |
Date | |
Source | Own work |
Author | Abjiklam |
Licensing
editI, the copyright holder of this work, hereby publish it under the following license:
![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)
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.
Code
editThe graph is generated by the following R script, inspired by this file.
library(RCurl)
library(reshape)
library(htmltab)
library(ggplot2)
library(stringr)
library(scales)
library(lubridate)
#get the tables from the url
theurl <- getURL("https://en.wikipedia.org/wiki/42nd_Quebec_general_election", ssl.verifyPeer=FALSE)
df <- htmltab(theurl, which=7)[, c(2, 4:8)]
names(df)[1] <- "Date"
party.colours <- c("#dd0000", "#9999ff", "#9900cc", "#ff8800", "#666666")
#format numerical and date data
df[is.na(df)] <- 0
df$Date <- as.Date(substr(df$Date, 9, 18))
for (i in c(2:6)) {
df[[i]] = as.numeric(sub("*", "", df[[i]], fixed=TRUE))/100
}
#reshape data to have candidate and support as variable
mdata <- melt(df[-nrow(df), ], id=c("Date"))
names(mdata)[2:3] <- c("Party", "Support")
election.2014 <- melt(df[nrow(df), ], id=c("Date"))
names(election.2014)[2:3] <- c("Party", "Support")
#make plot
d <- ggplot(mdata, aes(x=Date, y=Support, colour=Party))
d <- d + geom_point(alpha=0.5)
d <- d + geom_smooth(span=0.45, size=0.8, alpha=0.3, se=TRUE, show.legend=FALSE)
d <- d + scale_colour_manual(values=party.colours)
d <- d + labs(title="Opinion polls since the 2014 Quebec general election")
d <- d + scale_y_continuous(breaks=seq(0,1,0.05),
minor_breaks=seq(0,1,0.01),
labels=percent,
limits=c(0, 0.45))
d <- d + scale_x_date(labels=c("2014 Election",
format(seq(as.Date("2014-06-01"), as.Date("2018-10-01"), by="2 month"),
format="%b %Y")),
breaks=c(as.Date("2014-04-07"),
seq(as.Date("2014-06-01"), as.Date("2018-10-01"), by="2 month")),
minor_breaks=seq(as.Date("2014-05-01"), as.Date("2018-10-01"), by="month"))
d <- d + geom_point(data=election.2014, shape=5, size=5, show.legend=FALSE)
d <- d + geom_point(data=election.2014, size=2.5, show.legend=TRUE)
d <- d + geom_text(data=election.2014, show.legend=F,
aes(label=sprintf("%.1f", election.2014$Support*100)),
size=3.5, nudge_x=-15, hjust=1, color="#000000")
d <- d + theme(panel.grid.minor=element_line(size=0.2),
panel.grid.major=element_line(size=0.6))
d <- d + theme(axis.text.x=element_text(angle=45, hjust=1))
#save plot as "qc2018.svg"
svg(filename="qc2018.svg",
width=9,
height=6,
pointsize=12,
bg="transparent")
d
dev.off()
File history
Click on a date/time to view the file as it appeared at that time.
Date/Time | Thumbnail | Dimensions | User | Comment | |
---|---|---|---|---|---|
current | 21:45, 20 October 2016 | ![]() | 810 × 540 (248 KB) | Χ (talk | contribs) | cosmetic change |
13:36, 20 October 2016 | ![]() | 810 × 450 (246 KB) | Χ (talk | contribs) | User created page with UploadWizard |
You cannot overwrite this file.
File usage on Commons
There are no pages that use this file.
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 | 648pt |
---|---|
Height | 432pt |