File:Delegate gap for the 2016 Democratic Party presidential primaries.svg
From Wikimedia Commons, the free media repository
Jump to navigation
Jump to search
Size of this PNG preview of this SVG file: 800 × 364 pixels. Other resolutions: 320 × 145 pixels | 640 × 291 pixels | 1,024 × 465 pixels | 1,280 × 582 pixels | 2,560 × 1,164 pixels | 990 × 450 pixels.
Original file (SVG file, nominally 990 × 450 pixels, file size: 198 KB)
File information
Structured data
Captions
Summary
[edit]DescriptionDelegate gap for the 2016 Democratic Party presidential primaries.svg |
English: Delegate gap for the 2016 Democratic Party presidential primaries. Graph may not reflect the latest developments. Graph generated with an R script. |
Date | |
Source | Own work |
Author | Abjiklam |
Licensing
[edit]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.
Code
[edit]The graph is generated by the following R script:
library(RCurl)
library(reshape)
library(htmltab)
library(ggplot2)
#get the table from the url
theurl <- getURL("https://en.wikipedia.org/wiki/Template:2016USDem", ssl.verifyPeer=FALSE)
table <- htmltab(theurl)
#keep only the useful columns and name them
df <- table[, c(1, 2, 9, 12)]
names(df) <- c("Date", "State", "Clinton", "Sanders")
#transform strings into dates and numbers
df$Date = as.Date(substr(df[, 1], 9, 18))
df$Clinton = as.numeric(df$Clinton)
df$Sanders = as.numeric(df$Sanders)
#remove rows missing data
df = na.omit(df)
#Clinton is gold, Sanders is green
colors <- c("#D4AA00", "#228b22")
#data frame for number at end of path
number = tail(df, 1)
number$Label = tail(cumsum(df$Clinton-df$Sanders), 1)
#vertical adjustments
vtotal = -0.5
vcontests = c(1.4*(df$Clinton<df$Sanders)-0.4*(df$Clinton>df$Sanders)+0.5*(df$Sanders==df$Clinton))
vlabel = 0.3
#generate graph
d = ggplot(df, aes(x=reorder(State, Date))) +
geom_bar(aes(y=Clinton-Sanders, fill=Clinton-Sanders<0), stat="identity") +
scale_fill_manual(values=colors, labels=c("Clinton", "Sanders")) +
geom_path(aes(y=cumsum(Clinton-Sanders), group=1)) +
theme(axis.text.x=element_text(angle=90,hjust=1,vjust=vlabel)) +
labs(x="Contest", title="Pledged delegate gap", y="Gap", fill="Candidate") +
geom_text(data=number, show.legend=F,
aes(x=State, y=Label, label=abs(Label)), size=4, hjust=1, vjust=vtotal) +
geom_text(aes(y=Clinton-Sanders, label=abs(Clinton-Sanders), vjust=vcontests), size=3.5) +
scale_y_continuous(labels=abs, breaks=seq(-1000, 1000, 50), minor_breaks=seq(-1000, 1000, 10)) +
theme(plot.background = element_rect(fill="transparent",colour = NA)) +
theme(legend.background = element_rect(fill="transparent",colour = NA))
#display plot
svg(filename="gap.svg",
width=ceiling(nrow(df)/6)+1,
height=5,
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:55, 15 June 2016 | 990 × 450 (198 KB) | Χ (talk | contribs) | update | |
21:54, 8 June 2016 | 990 × 450 (196 KB) | Χ (talk | contribs) | update | ||
14:10, 7 June 2016 | 900 × 450 (183 KB) | Χ (talk | contribs) | update VI and PR | ||
20:27, 18 May 2016 | 810 × 450 (177 KB) | Double Schiara (talk | contribs) | Update 18 May | ||
16:38, 11 May 2016 | 810 × 450 (178 KB) | Double Schiara (talk | contribs) | Update 11 May (ignore previous version that I have uploaded) | ||
16:35, 11 May 2016 | 810 × 450 (178 KB) | Double Schiara (talk | contribs) | Update May 11 | ||
13:22, 5 May 2016 | 810 × 450 (175 KB) | Double Schiara (talk | contribs) | Update --~~~ | ||
19:29, 28 April 2016 | 810 × 450 (174 KB) | Χ (talk | contribs) | update | ||
13:26, 27 April 2016 | 810 × 450 (173 KB) | Χ (talk | contribs) | update | ||
22:20, 21 April 2016 | 630 × 450 (157 KB) | Χ (talk | contribs) | candidate order |
You cannot overwrite this file.
File usage on Commons
There are no pages that use this file.
File usage on other wikis
The following other wikis use this file:
- Usage on en.wikipedia.org
- Usage on simple.wikipedia.org
- Usage on sv.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 | 792pt |
---|---|
Height | 360pt |