Last active
October 20, 2015 04:59
-
-
Save matt-bernhardt/bf5897a0f1c12c564952 to your computer and use it in GitHub Desktop.
Code necessary to generate plots illustrating the evolution of playing time. Writeups for this plot can be found at http://www.massivereportdata.com/blog/2015/10/20/updating-the-evolution-of-playing-time/ and http://www.massivereportdata.com/blog/2015/09/26/plotting-the-evolution-of-playing-time/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Read in teams | |
team11 <- read.csv("minutes_evolution_11_2015.csv") | |
team12 <- read.csv("minutes_evolution_12_2015.csv") | |
team13 <- read.csv("minutes_evolution_13_2015.csv") | |
team14 <- read.csv("minutes_evolution_14_2015.csv") | |
team15 <- read.csv("minutes_evolution_15_2015.csv") | |
team16 <- read.csv("minutes_evolution_16_2015.csv") | |
team17 <- read.csv("minutes_evolution_17_2015.csv") | |
team18 <- read.csv("minutes_evolution_18_2015.csv") | |
team19 <- read.csv("minutes_evolution_19_2015.csv") | |
team20 <- read.csv("minutes_evolution_20_2015.csv") | |
team42 <- read.csv("minutes_evolution_42_2015.csv") | |
team43 <- read.csv("minutes_evolution_43_2015.csv") | |
team44 <- read.csv("minutes_evolution_44_2015.csv") | |
team45 <- read.csv("minutes_evolution_45_2015.csv") | |
team340 <- read.csv("minutes_evolution_340_2015.csv") | |
team427 <- read.csv("minutes_evolution_427_2015.csv") | |
team463 <- read.csv("minutes_evolution_463_2015.csv") | |
team479 <- read.csv("minutes_evolution_479_2015.csv") | |
team506 <- read.csv("minutes_evolution_506_2015.csv") | |
team547 <- read.csv("minutes_evolution_547_2015.csv") | |
colors=c("#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00","#a65628","#f781bf") | |
# Define plot | |
plotPTEvolution <- function(team,name,representative,gameCount) { | |
par(new=F) | |
separator = 1 | |
j = 1 | |
for (i in names(team)) { | |
if (j==representative) { | |
plot(team[[i]],ylim=c(0,1),type="l",xlab="Game number",ylab="Percentage of playing time",main=name,col=colors[j%%6+1],pch=19,las=1,mai=c(1,2,1,8),xlim=c(1,36),cex.axis=0.7,cex.lab=0.85,yaxt="n") | |
axis(2,at=pretty(team[[i]]), lab=paste0(pretty(team[[i]]) * 100,"%"), las=TRUE, cex.axis=0.7) | |
} else { | |
plot(team[[i]],ylim=c(0,1),type="l",xlab="",ylab="",main="",col=colors[j%%6+1],pch=19,mai=c(0,2,1,8),axes=FALSE,mar=c(1,2,1,8),xlim=c(1,36)) | |
} | |
text(gameCount+separator,team[[gameCount,i]],names(team[i]),adj=c(0,0.5),cex=0.5) | |
par(new=T) | |
j = j + 1 | |
} | |
return(TRUE) | |
} | |
# Example plots for Wil Trapp and Emanuel Pogatetz | |
par(mfrow=c(1,2)) | |
plot(team11$Trapp,ylim=c(0,1),type="l",xlab="Game number",ylab="Percentage of playing time",main="Wil Trapp",col="red",pch=19,las=1,mai=c(1,2,1,8),xlim=c(1,36),cex.axis=0.7,cex.lab=0.85,yaxt="n") | |
plot(team11$Pogatetz,ylim=c(0,1),type="l",xlab="Game number",ylab="Percentage of playing time",main="Emanuel Pogatetz",col="red",pch=19,las=1,mai=c(1,2,1,8),xlim=c(1,36),cex.axis=0.7,cex.lab=0.85,yaxt="n") | |
# Choose for single-team plots | |
par(mfrow=c(1,1)) | |
# Choose for an overall league plot with all teams | |
par(mfrow=c(4,5)) | |
# League overview | |
plotPTEvolution(team13,"Chicago Fire", 2, 33) | |
plotPTEvolution(team14,"Colorado Rapids", 6, 32) | |
plotPTEvolution(team11,"Columbus Crew", 24, 33) | |
plotPTEvolution(team12,"DC United", 4, 33) | |
plotPTEvolution(team16,"FC Dallas", 19, 33) | |
plotPTEvolution(team427,"Houston Dynamo", 12, 33) | |
plotPTEvolution(team19,"Los Angeles Galaxy", 24, 33) | |
plotPTEvolution(team45,"Montreal Impact", 5, 33) | |
plotPTEvolution(team15,"New England Revolution", 16, 33) | |
plotPTEvolution(team547,"New York City", 29, 33) | |
plotPTEvolution(team20,"New York Red Bulls", 10, 33) | |
plotPTEvolution(team506,"Orlando City", 5, 33) | |
plotPTEvolution(team479,"Philadelphia Union", 18, 33) | |
plotPTEvolution(team42,"Portland Timbers", 6, 33) | |
plotPTEvolution(team340,"Real Salt Lake", 24, 33) | |
plotPTEvolution(team17,"San Jose Earthquakes", 11, 33) | |
plotPTEvolution(team43,"Seattle Sounders", 10, 33) | |
plotPTEvolution(team18,"Sporting Kansas City", 2, 32) | |
plotPTEvolution(team463,"Toronto FC", 4, 33) | |
plotPTEvolution(team44,"Vancouver Whitecaps", 1, 33) | |
# Game-specific preview | |
par(mfrow=c(1,2)) | |
plotPTEvolution(team11,"Columbus Crew", 24, 33) | |
plotPTEvolution(team12,"DC United", 4, 33) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Afful | Barson | Campbell | Clark | Finlay | Francis | George | Grana | Higuain | Jimenez | Kamara | Klute | Mabwati | McInerney | Meram | Parkhurst | Pogatetz | Saeid | Sauro | Schoenfeld | Speas | Steindorsson | Tchani | Trapp | Wahl | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 0 | 0 | 1 | 1 | 1 | 0 | 1 | 0.833333333 | 0.166666667 | 1 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0.111111111 | 0.111111111 | 0.888888889 | 0.888888889 | 1 | 0 | |
0 | 0 | 0 | 1 | 0.883333333 | 1 | 0.077777778 | 0.961111111 | 0.916666667 | 0.2 | 1 | 0 | 0 | 0 | 0.5 | 1 | 1 | 0.422222222 | 0 | 0.055555556 | 0.055555556 | 0.483333333 | 0.444444444 | 1 | 0 | |
0 | 0 | 0 | 1 | 0.862962963 | 0.666666667 | 0.051851852 | 0.974074074 | 0.918518519 | 0.192592593 | 1 | 0.303703704 | 0 | 0 | 0.333333333 | 1 | 1 | 0.614814815 | 0 | 0.066666667 | 0.133333333 | 0.559259259 | 0.62962963 | 0.666666667 | 0 | |
0 | 0.055555556 | 0 | 1 | 0.897222222 | 0.5 | 0.038888889 | 0.730555556 | 0.688888889 | 0.338888889 | 1 | 0.477777778 | 0 | 0 | 0.5 | 1 | 0.75 | 0.586111111 | 0 | 0.05 | 0.294444444 | 0.475 | 0.722222222 | 0.625 | 0.25 | |
0 | 0.095555556 | 0 | 1 | 0.882222222 | 0.4 | 0.031111111 | 0.784444444 | 0.751111111 | 0.271111111 | 0.986666667 | 0.531111111 | 0 | 0 | 0.6 | 1 | 0.8 | 0.668888889 | 0 | 0.053333333 | 0.235555556 | 0.415555556 | 0.777777778 | 0.5 | 0.2 | |
0 | 0.07962963 | 0 | 1 | 0.881481481 | 0.453703704 | 0.025925926 | 0.82037037 | 0.792592593 | 0.246296296 | 0.988888889 | 0.488888889 | 0 | 0 | 0.62962963 | 1 | 0.833333333 | 0.724074074 | 0 | 0.044444444 | 0.196296296 | 0.383333333 | 0.814814815 | 0.416666667 | 0.166666667 | |
0 | 0.068253968 | 0 | 1 | 0.898412698 | 0.531746032 | 0.022222222 | 0.846031746 | 0.822222222 | 0.211111111 | 0.96984127 | 0.419047619 | 0 | 0 | 0.644444444 | 1 | 0.803174603 | 0.763492063 | 0 | 0.058730159 | 0.168253968 | 0.366666667 | 0.841269841 | 0.357142857 | 0.196825397 | |
0 | 0.059722222 | 0 | 1 | 0.911111111 | 0.527777778 | 0.019444444 | 0.830555556 | 0.844444444 | 0.219444444 | 0.973611111 | 0.429166667 | 0 | 0 | 0.626388889 | 1 | 0.827777778 | 0.793055556 | 0 | 0.051388889 | 0.147222222 | 0.383333333 | 0.861111111 | 0.3125 | 0.172222222 | |
0 | 0.05308642 | 0 | 1 | 0.920987654 | 0.580246914 | 0.017283951 | 0.738271605 | 0.861728395 | 0.30617284 | 0.969135802 | 0.381481481 | 0 | 0 | 0.665432099 | 1 | 0.84691358 | 0.782716049 | 0 | 0.05308642 | 0.130864198 | 0.343209877 | 0.87654321 | 0.277777778 | 0.186419753 | |
0 | 0.047777778 | 0 | 1 | 0.915555556 | 0.622222222 | 0.047777778 | 0.664444444 | 0.875555556 | 0.375555556 | 0.964444444 | 0.343333333 | 0 | 0 | 0.666666667 | 1 | 0.862222222 | 0.741111111 | 0 | 0.055555556 | 0.117777778 | 0.322222222 | 0.888888889 | 0.25 | 0.167777778 | |
0 | 0.043434343 | 0 | 1 | 0.908080808 | 0.656565657 | 0.134343434 | 0.604040404 | 0.883838384 | 0.341414141 | 0.966666667 | 0.403030303 | 0 | 0 | 0.696969697 | 1 | 0.874747475 | 0.673737374 | 0 | 0.051515152 | 0.11010101 | 0.308080808 | 0.898989899 | 0.227272727 | 0.152525253 | |
0 | 0.039814815 | 0 | 1 | 0.915740741 | 0.685185185 | 0.123148148 | 0.553703704 | 0.827777778 | 0.372222222 | 0.969444444 | 0.393518519 | 0 | 0 | 0.680555556 | 0.931481481 | 0.867592593 | 0.700925926 | 0 | 0.047222222 | 0.100925926 | 0.324074074 | 0.907407407 | 0.208333333 | 0.223148148 | |
0 | 0.113675214 | 0.076923077 | 1 | 0.900854701 | 0.693162393 | 0.190598291 | 0.511111111 | 0.81965812 | 0.35982906 | 0.916239316 | 0.363247863 | 0 | 0 | 0.705128205 | 0.85982906 | 0.877777778 | 0.723931624 | 0 | 0.120512821 | 0.114529915 | 0.299145299 | 0.837606838 | 0.192307692 | 0.205982906 | |
0 | 0.105555556 | 0.071428571 | 1 | 0.89047619 | 0.715079365 | 0.176984127 | 0.474603175 | 0.832539683 | 0.405555556 | 0.922222222 | 0.337301587 | 0 | 0 | 0.675396825 | 0.86984127 | 0.815079365 | 0.735714286 | 0 | 0.11984127 | 0.123809524 | 0.328571429 | 0.849206349 | 0.178571429 | 0.262698413 | |
0 | 0.098518519 | 0.066666667 | 1 | 0.893333333 | 0.734074074 | 0.165185185 | 0.442962963 | 0.842962963 | 0.445185185 | 0.927407407 | 0.314814815 | 0 | 0 | 0.697037037 | 0.878518519 | 0.827407407 | 0.753333333 | 0 | 0.116296296 | 0.116296296 | 0.306666667 | 0.859259259 | 0.166666667 | 0.245185185 | |
0 | 0.109027778 | 0.0625 | 1 | 0.9 | 0.750694444 | 0.158333333 | 0.415277778 | 0.840277778 | 0.463194444 | 0.931944444 | 0.295138889 | 0 | 0 | 0.7125 | 0.886111111 | 0.838194444 | 0.76875 | 0 | 0.109027778 | 0.109027778 | 0.3 | 0.868055556 | 0.15625 | 0.229861111 | |
0 | 0.120915033 | 0.058823529 | 1 | 0.905882353 | 0.759477124 | 0.149019608 | 0.390849673 | 0.849673203 | 0.476470588 | 0.935947712 | 0.277777778 | 0 | 0 | 0.714379085 | 0.892810458 | 0.847712418 | 0.782352941 | 0 | 0.102614379 | 0.102614379 | 0.297385621 | 0.875816993 | 0.147058824 | 0.222222222 | |
0 | 0.114197531 | 0.055555556 | 1 | 0.911111111 | 0.772839506 | 0.140740741 | 0.369135802 | 0.856790123 | 0.505555556 | 0.938888889 | 0.262345679 | 0 | 0 | 0.718518519 | 0.898765432 | 0.85617284 | 0.794444444 | 0 | 0.097530864 | 0.09691358 | 0.292592593 | 0.882716049 | 0.140123457 | 0.209876543 | |
0 | 0.108187135 | 0.052631579 | 1 | 0.915789474 | 0.784795322 | 0.133333333 | 0.349707602 | 0.864327485 | 0.497660819 | 0.942105263 | 0.28245614 | 0 | 0 | 0.733333333 | 0.904093567 | 0.856140351 | 0.778947368 | 0 | 0.1 | 0.091812865 | 0.277192982 | 0.888888889 | 0.159064327 | 0.198830409 | |
0 | 0.147777778 | 0.05 | 1 | 0.92 | 0.795555556 | 0.126666667 | 0.332222222 | 0.871111111 | 0.472777778 | 0.944444444 | 0.273333333 | 0 | 0 | 0.732777778 | 0.908888889 | 0.813333333 | 0.74 | 0 | 0.095555556 | 0.087222222 | 0.277222222 | 0.894444444 | 0.201111111 | 0.238888889 | |
0 | 0.15026455 | 0.047619048 | 1 | 0.923809524 | 0.805291005 | 0.120634921 | 0.316402116 | 0.877248677 | 0.45026455 | 0.947089947 | 0.298412698 | 0 | 0 | 0.740740741 | 0.913227513 | 0.774603175 | 0.723280423 | 0 | 0.091005291 | 0.083068783 | 0.268783069 | 0.880952381 | 0.239153439 | 0.275132275 | |
0 | 0.188888889 | 0.045454545 | 1 | 0.925252525 | 0.814141414 | 0.115151515 | 0.302020202 | 0.876767677 | 0.42979798 | 0.949494949 | 0.284848485 | 0.002020202 | 0 | 0.74040404 | 0.917171717 | 0.739393939 | 0.696464646 | 0 | 0.086868687 | 0.079292929 | 0.268686869 | 0.886363636 | 0.273737374 | 0.308080808 | |
0 | 0.208695652 | 0.043478261 | 1 | 0.906763285 | 0.822222222 | 0.110144928 | 0.288888889 | 0.882125604 | 0.426570048 | 0.951690821 | 0.272463768 | 0.023671498 | 0 | 0.751690821 | 0.920772947 | 0.707246377 | 0.677294686 | 0 | 0.083091787 | 0.075845411 | 0.257004831 | 0.880193237 | 0.30531401 | 0.338164251 | |
0 | 0.211111111 | 0.041666667 | 1 | 0.910648148 | 0.787962963 | 0.105555556 | 0.276851852 | 0.886574074 | 0.439351852 | 0.953703704 | 0.302777778 | 0.022685185 | 0.000462963 | 0.725925926 | 0.924074074 | 0.677777778 | 0.649074074 | 0 | 0.07962963 | 0.072685185 | 0.282407407 | 0.885185185 | 0.334259259 | 0.365740741 | |
0.026666667 | 0.202666667 | 0.04 | 1 | 0.914222222 | 0.796444444 | 0.101333333 | 0.265777778 | 0.891111111 | 0.435111111 | 0.955555556 | 0.290666667 | 0.032 | 0.000444444 | 0.726666667 | 0.927111111 | 0.650666667 | 0.623111111 | 0 | 0.076444444 | 0.069777778 | 0.271111111 | 0.889777778 | 0.360888889 | 0.391111111 | |
0.055555556 | 0.194871795 | 0.038461538 | 1 | 0.917521368 | 0.804273504 | 0.097435897 | 0.255555556 | 0.895299145 | 0.426923077 | 0.94957265 | 0.279487179 | 0.038461538 | 0.011538462 | 0.726068376 | 0.92991453 | 0.625641026 | 0.599145299 | 0 | 0.073504274 | 0.067094017 | 0.260683761 | 0.894017094 | 0.385470085 | 0.414529915 | |
0.090534979 | 0.187654321 | 0.037037037 | 1 | 0.920576132 | 0.811522634 | 0.09382716 | 0.246090535 | 0.898765432 | 0.411111111 | 0.951028807 | 0.269135802 | 0.060493827 | 0.011111111 | 0.712757202 | 0.932510288 | 0.602469136 | 0.577366255 | 0 | 0.071193416 | 0.064609053 | 0.251028807 | 0.897942387 | 0.408230453 | 0.436213992 | |
0.087301587 | 0.180952381 | 0.035714286 | 1 | 0.923412698 | 0.782539683 | 0.09047619 | 0.237301587 | 0.902380952 | 0.432142857 | 0.917063492 | 0.295238095 | 0.058333333 | 0.038095238 | 0.687301587 | 0.934920635 | 0.580952381 | 0.569444444 | 0.002777778 | 0.076984127 | 0.08531746 | 0.242063492 | 0.901587302 | 0.429365079 | 0.453571429 | |
0.118773946 | 0.174712644 | 0.034482759 | 1 | 0.919157088 | 0.785440613 | 0.087356322 | 0.229118774 | 0.905747126 | 0.417241379 | 0.919923372 | 0.289655172 | 0.063218391 | 0.036781609 | 0.696168582 | 0.937164751 | 0.562835249 | 0.549808429 | 0.002681992 | 0.074329502 | 0.082375479 | 0.233716475 | 0.904980843 | 0.449042146 | 0.472413793 | |
0.148148148 | 0.168888889 | 0.033333333 | 1 | 0.919259259 | 0.759259259 | 0.084444444 | 0.221481481 | 0.908888889 | 0.408518519 | 0.922592593 | 0.308148148 | 0.061111111 | 0.035555556 | 0.702222222 | 0.939259259 | 0.546666667 | 0.531481481 | 0.002592593 | 0.071851852 | 0.07962963 | 0.23 | 0.908148148 | 0.467407407 | 0.49 | |
0.17562724 | 0.16344086 | 0.032258065 | 1 | 0.912903226 | 0.76702509 | 0.08172043 | 0.214336918 | 0.911827957 | 0.398566308 | 0.925089606 | 0.298207885 | 0.068100358 | 0.034408602 | 0.708602151 | 0.941218638 | 0.529032258 | 0.523297491 | 0.002508961 | 0.06953405 | 0.077060932 | 0.222580645 | 0.902150538 | 0.484587814 | 0.506451613 | |
0.201388889 | 0.158333333 | 0.03125 | 1 | 0.906597222 | 0.774305556 | 0.079166667 | 0.207638889 | 0.914583333 | 0.386111111 | 0.927430556 | 0.288888889 | 0.075 | 0.034722222 | 0.717708333 | 0.943055556 | 0.5125 | 0.538194444 | 0.032291667 | 0.067361111 | 0.074652778 | 0.215625 | 0.905208333 | 0.469444444 | 0.490625 | |
0.225589226 | 0.153535354 | 0.03030303 | 1 | 0.909427609 | 0.781144781 | 0.076767677 | 0.201346801 | 0.917171717 | 0.374410774 | 0.92962963 | 0.28013468 | 0.072727273 | 0.033670034 | 0.725925926 | 0.944781145 | 0.496969697 | 0.521885522 | 0.061616162 | 0.065656566 | 0.072390572 | 0.209090909 | 0.908080808 | 0.485521886 | 0.475757576 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment