[This post has been revised to credit the original author of the R code behind this graphic]
Inspired by Tufte's classic visualization of New York City weather in 2013, Brad Boehmke used the R language to create a similar story about the weather in Dayton, Ohio in 2014.
Click the image for Brad's lovely tutorial on using R to create the image above. The R code is easily adapted to display data for any of the other cities provided in the University of Dayton Average Daily Temperature Archive. Alex Bresler used the same code to chart New York City weather in 2014:
(Click the image to view the zoomable SVG version.) The R code to create the NYC plot is available on GitHub. And here's my rendition for Chicago:
This one doesn't include the annotations, since the labels on the Brad and Alex's charts were added the ggplot2 object directly (which I didn't attempt for Chicago). But the annotations are really the highlight of the plot: following Tufte, these are what tell the story of NYC's weather last year. (But you can sure see that Chicago was damn cold last winter!)
RPubs: Dayton’s Weather in 2014
Unfortunately Bresler didn't properly cite his source code. You can see the original recreation of the Tufte graphic here:
http://rpubs.com/bradleyboehmke/weather_graphic
Posted by: Brad Boehmke | January 21, 2015 at 20:33
Thanks for letting us know, Brad! I'll update the post accordingly.
Posted by: David Smith | January 22, 2015 at 06:33
Great graphics and thanks for sharing the code.
I think I see an extra day beyond Dec 31 plotted, and that may be due to presence of leap days in certain years. Filtering the dataset to remove the leap days may help
DAY <- DAY %>% filter(Month!=2 | Day!=29)
Posted by: Sarraf | January 26, 2015 at 05:01
To add a southern point of view, here is a daily temperature and rain chart for a weather station in North Parramatta (slightly west of Sydney, Australia), displaying the 2014 daily temperature on the min/max band for the decade 1971-1980. Leap days have been removed from the historical data as there was no leap day in 2014. The interesting thing is that almost all of the "records" were within the day to day variation in the minimum and maximum temperatures.
The R code is:
require(plotrix)
par(mar=c(5,4,4,4))
plot(npmax2014,type="n",col="red",ylim=c(-10,41),axes=FALSE,
main="Parramatta temperature and rainfall 2014",xlab="Month",
ylab="")
polygon(c(1:365,365:1),c(npmax71_80,rev(npmin71_80)),
border="orange",col="lightyellow")
lines(npmax2014,col="red")
lines(npmin2014,col="blue")
points((1:365)[maxrec],npmax2014[maxrec]+0.2,col="red")
points((1:365)[minrec],npmin2014[minrec]-0.2,col="blue")
staxlab(1,at=c(15,45,75,105,135,166,196,227,257,288,319,349),
labels=month.abb)
axis(2,at=seq(0,40,by=10))
mtext(side=2,text="Temperature (degrees C)",line=2.5,at=25)
par(new=TRUE)
plot(npr2014,type="l",col="green",ylim=c(0,200),axes=FALSE,
xlab="",ylab="")
axis(4,at=seq(0,50,by=10),col="green")
box()
mtext(side=4,line=2,at=30,text="Daily rainfall (mm)",col="green")
text(182,200,paste(sum(maxrec),"daily maximum records"),col="red")
text(70,45,paste(sum(minrec),"daily minimum records"),col="blue")
legend(135,190,c("Daily max.","Daily min.","Rain"),lty=1,
col=c("red","blue","green"))
Posted by: Jim Lemon | February 11, 2015 at 03:03