« New Introductory R Course for Health Analytics | Main | A first look at Spark »

January 21, 2015

Comments

Feed You can follow this conversation by subscribing to the comment feed for this post.

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

Thanks for letting us know, Brad! I'll update the post accordingly.

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)

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"))

The comments to this entry are closed.

Search Revolutions Blog




Got comments or suggestions for the blog editor?
Email David Smith.
Follow revodavid on Twitter Follow David on Twitter: @revodavid
Get this blog via email with Blogtrottr