library(readxl)
download.file("https://environment.govt.nz/assets/publications/climate-change/Time-series-emissions-data-by-category-presented-in-AR4-Excel-xlsx.xlsx","Time-series-emissions-data-by-category-presented-in-AR4-Excel-xlsx")
data <- read_excel("Time-series-emissions-data-by-category-presented-in-AR4-Excel-xlsx", sheet = "AR4 - All gases",skip=10,col_types = c("guess"))
domestic_aviation <- as.numeric(data[82,3:34])
international_aviation <- as.numeric(data[311,3:34])
year <- c(1990:2021)
nz_aviation <-as.data.frame(cbind(year,domestic_aviation,international_aviation))
nz_aviation[["total"]] <- nz_aviation[["domestic_aviation"]] + nz_aviation[["international_aviation"]]
svg(filename="NZ-aviation-ghgs-2021-720.svg", width = 8, height = 6, pointsize = 12, onefile = FALSE, family = "sans", bg = "white", antialias = c("default", "none", "gray", "subpixel"))
#png("NZ-aviation-ghgs-2021-560.png", bg="white", width=560, height=420, pointsize = 12)
par(mar=c(2.7,2.7,1,1)+0.1)
plot(nz_aviation[["year"]],nz_aviation[["total"]]/1000,ylim=c(0,5.25), xlim=c(1989,2021),tck=0.01,axes=FALSE,ann=FALSE, type="n",las=1)
axis(side=1, tck=0.01, las=0, lwd = 1, at = c(1990:2021), labels = c(1990:2021), tick = TRUE)
axis(side=2, tck=0.01, las=2, line = NA,lwd = 1, at = c(0,1,2,3,4,5), labels = c(0,1,2,3,4,5),tick = TRUE)
axis(side=4, tck=0.01, at = c(0,1,2,3,4,5), labels = FALSE, tick = TRUE)
box(lwd=1)
lines(nz_aviation[["year"]],nz_aviation[["total"]]/1000,col="#E41A1C",lwd=1)
points(nz_aviation[["year"]],nz_aviation[["total"]]/1000,col="#E41A1C",cex=1.1,pch=16)
lines(nz_aviation[["year"]],nz_aviation[["domestic_aviation"]]/1000,col="#377EB8",lwd=1)
points(nz_aviation[["year"]],nz_aviation[["domestic_aviation"]]/1000,col="#377EB8",cex=1,pch=15)
lines(nz_aviation[["year"]],nz_aviation[["international_aviation"]]/1000,col="#4DAF4A",lwd=1)
points(nz_aviation[["year"]],nz_aviation[["international_aviation"]]/1000,col="#4DAF4A",cex=1,pch=17)
mtext(side=1,line=-1.5,cex=1,"Data: New Zealand’s Greenhouse Gas Inventory 1990 – 2021 MfE 2023 Report ME 1750 \nTime-series-emissions-data-by-category-presented-in-AR4-Excel-xlsx.xlsx")
mtext(side=3,cex=1.5, line=-2,expression(paste("New Zealand aviation emissions 1990 2021")) )
mtext(side=2,cex=1, line=-1.5,expression(paste("million tonnes C", O[2], "-e")))
mtext(side=4,cex=0.75, line=0.05,R.version.string)
legend(1990,4.75, bty = "n",cex=1.1, c("Total NZ aviation emissions","International aviation emissions","Domestic aviation emissions"), col = c("#E41A1C","#4DAF4A","#377EB8") , text.col = 1, lty = 1, pch = c(16,17,15))
dev.off()