The Race to the F1 2012 Drivers’ Championship – Initial Sketches

In part inspired by the chart described in The electoral map sans the map, I thought I’d start mulling over a quick sketch showing the race to the 2012 Formula One Drivers’ Championship.

The chart needs to show tension somehow, so in this first really quick and simple rough sketch, you really do have to put yourself in the graph and start reading it from left to right:

The data is pulled in from the Ergast API as JSON data, which is then parsed and visualised using R:

require(RJSONIO)
require(ggplot2)
#initialise a data frame
champ <- data.frame(round=numeric(),
driverID=character(),
position=numeric(), points=numeric(),wins=numeric(),
stringsAsFactors=FALSE)
#This is a fudge at the moment - should be able to use a different API call to
#get the list of races to date, rather than hardcoding latest round number
for (j in 1:18){
resultsURL=paste("http://ergast.com/api/f1/2012/",j,"/driverStandings",".json",sep='')
print(resultsURL)
results.data.json=fromJSON(resultsURL,simplify=FALSE)
rd=results.data.json$MRData$StandingsTable$StandingsLists[[1]]$DriverStandings
for (i in 1:length(rd)){
champ=rbind(champ,data.frame(round=j, driverID=rd[[i]]$Driver$driverId,
position=as.numeric(as.character(rd[[i]]$position)),
points=as.numeric(as.character(rd[[i]]$points)),
wins=as.numeric(as.character(rd[[i]]$wins)) ))
}
}
champ
#Horrible fudge - should really find a better way of filtering?
test2=subset(champ,( driverID=='vettel' | driverID=='alonso' | driverID=='raikkonen'|driverID=='webber' | driverID=='hamilton'|driverID=='button' ))
#Really rough sketch, in part inspired by http://junkcharts.typepad.com/junk_charts/2012/11/the-electoral-map-sans-the-map.html
ggplot(test2)+geom_line(aes(x=round,y=points,group=driverID,col=driverID))+labs(title="F1 2012 - Race to the Championship")
#I wonder if it would be worth annotating the chart with labels explaining any DNF reasons at parts where points stall?

So, that’s the quickest and dirtiest chart I could think of – where to take this next? One way would be to start making the chart look cleaner; another possibility would be to start looking at adding labels, highlights, and maybe pushing all but ALO and VET into the background? (GDS do some nice work in this vein, eg Updating the GOV.UK Performance Dashboard; this StoryTellingWithData post on stacked bar charts also has some great ideas about how to make simple, clean and effective use of text and highlighting…).

Let’s try cleaning it up a little, and then highlight the championship contenders?