Created
August 20, 2017 05:25
-
-
Save thoughtfulbloke/e227d161ed52309d73f5a9cd8009f933 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# my graph for when people say Climate Change is due to natural processes | |
# modify CO2_label and natural_label to suit their individual arguement wording | |
co2_label <- "Trend caused by CO2 added by people (what climate change is about)" | |
natural_label <- "Variation caused by natural events (what you are talking about)" | |
co2 = read.table("ftp://aftp.cmdl.noaa.gov/products/trends/co2/co2_annmean_mlo.txt") | |
temp = read.table("https://climate.nasa.gov/system/internal_resources/details/original/647_Global_Temperature_Data_File.txt", | |
header=FALSE) | |
names(co2) = c("year", "co2", "unc") | |
names(temp) = c("year", "raw_temp", "smoothed_temp") | |
dta <- merge(co2,temp, by="year") | |
plot(dta$co2, dta$raw_temp, pch=13, cex=0.5, frame.plot=FALSE, xlab="co2", ylab="temperature", | |
main="Global CO2 and Temperature 1959 to 2016") | |
lm_model <- lm(raw_temp ~ co2, data=dta) | |
abline(lm_model, col="blue", lwd=2) | |
annaul_var <- data.frame(co2=dta$co2, temp=dta$raw_temp, res=lm_model$residuals) | |
apply(annaul_var,1, function(x){lines(c(x[1],x[1]), c(x[2],x[2]-x[3]), lty=2, col="red")}) | |
legend("topleft", legend=c(co2_label, natural_label), | |
lwd=c(2,1), lty=c(1,2), col=c("blue","red"), cex=0.75, bty="n", y.intersp=1.3) | |
text(365,-0.1, "https://gist.github.com/anonymous/5bd0d77ea75fc68ff19f8b432d4cebbd", cex=0.5) | |
text(340,0.6, "source CO2: NOAA, source temp: NASA", cex=0.5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment