url <- c("https://www.niwa.co.nz/sites/niwa.co.nz/files/NZT7_Adjusted_Annual_TMean2018_Web-updated-jan-2019.xlsx")
file <- c("NZT7_Adjusted_Annual_TMean2018_Web-updated-jan-2019.xlsx")
download.file(url, file)
library(readxl)
t7data <-read_excel("NZT7_Adjusted_Annual_TMean2018_Web-updated-jan-2019.xlsx", sheet = "NZT7_Adjusted_TMean2016_Web", range ="Q12:Q122", col_names = T, skip =11,col_types = c("guess"))
year <-read_excel("NZT7_Adjusted_Annual_TMean2018_Web-updated-jan-2019.xlsx", sheet = "NZT7_Adjusted_TMean2016_Web", range ="A12:A122", col_names = T, skip =11,col_types = c("guess"))
t7data<-cbind(year,t7data)
names(t7data)<-c("Year","Anomaly")
# add 2019 annual anomaly 0.76 C ref https://www.nzherald.co.nz/environment/news/article.cfm?c_id=39&objectid=12299091
t7data <- rbind(t7data,c(2019,0.76))
# add 2020 anomaly 0.63 https://niwa.co.nz/climate/summaries/annual-climate-summary-2020
t7data <- rbind(t7data,c(2020,0.63))
# add 2021 anomaly 0.95 https://niwa.co.nz/climate/summaries/annual-climate-summary-2021
t7data <- rbind(t7data,c(2021,0.95))
# add 2022 anomaly https://niwa.co.nz/climate/summaries/annual-climate-summary-2022
t7data <- rbind(t7data,c(2022,1.15))
# add 2023 anomaly https://niwa.co.nz/climate/summaries/annual-climate-summary-2023
t7data <- rbind(t7data,c(2023,0.87))
# create graph
svg(filename="NZ-T7-land-temp-anom-2022-720by540-v1.svg", width = 8, height = 6, pointsize = 14, onefile = FALSE, family = "sans", bg = "white", antialias = c("default", "none", "gray", "subpixel"))
par(mar=c(2.7,2.7,1,1)+0.1)
plot(t7data[["Year"]],t7data[["Anomaly"]],ylim=c(-1.5,1.45),xlim=c(1905,2023),tck=0.01,axes=FALSE,ann=FALSE, type="l",col="1",lwd=1,las=1)
axis(side=1, tck=0.01, las=0,tick=TRUE)
axis(side=2, tck=0.01, las=0,tick=TRUE,las=1)
box()
lines(t7data[["Year"]],t7data[["Anomaly"]],col="1",lwd=1)
points(t7data[["Year"]],t7data[["Anomaly"]],col="#000099",pch=19)
abline(lm(t7data[["Anomaly"]]~t7data[["Year"]]),col="#000099",lwd=2,lty=1)
mtext(side=1,cex=0.7,line=-1.1,"Data: NIWA Seven-station series temperature data\n https://www.niwa.co.nz/sites/niwa.co.nz/files/NZT7_Adjusted_Annual_TMean2018_Web-updated-jan-2019.xlsx")
mtext(side=3,cex=1.7, line=-4,expression(paste("New Zealand Mean Land Surface \nTemperature Anomalies 1909 - 2023")) )
mtext(side=2,cex=1, line=-1.3,"Temperature anomaly C vs 1981-2010 mean")
legend(1910, 1,bty='n',bg="white", cex = 0.8, c(paste("Mean", c("annual anomaly", "lowess smoothed anomaly 11 years f = 0.1"))),pch=c(19,NA),lty=c(1,1),lwd=c(1,3),col=c("#000099","#CC0000"))
mtext(side=4,cex=0.75, line=0.05,R.version.string)
abline(h=0,col="darkgray")
dev.off()