Trend

Welcome to #30DayChartChallenge 2022 day 25

Networks
Published

April 25, 2022

Source:

  1. All PaleoTemps - Wikipedia: http://gergs.net/all_palaeotemps-2/
  2. Nasa temperature: https://climate.nasa.gov/vital-signs/global-temperature/
library(tidyverse)
df <- read.csv("https://data.giss.nasa.gov/gistemp/graphs/graph_data/Global_Mean_Estimates_based_on_Land_and_Ocean_Data/graph.txt",
         header = F,
         sep = "", 
         dec = ".",
         skip=5,
         col.names=c("year","avg","lowess"))

df%>%summary
df%>%
  filter(year==2020)
ggplot(df,aes(x=year,y=avg)) +
  geom_line(color="grey70",alpha=0.7,size=1) +
  geom_point(shape=21,stroke=1,color="grey70",fill="white")+
  geom_line(aes(y=lowess),inherit.aes = T,color="black",size=0.8)+
  geom_point(x=2020,y=0.94,size=3,color="red")+
  scale_x_continuous(breaks=seq(1880,2021,20),expand=c(0,0.05))+
  scale_y_continuous(expand=c(0,0),
                     limits=c(-0.5,1.5),
                     sec.axis = dup_axis())+
  labs(title="GLOBAL LAND-OCEAN TEMPERATURE INDEX",
       subtitle = "Data source: NASA's Goddard Institute for Space Studies (GISS).\nCredit: NASA/GISS\n\n",
       caption="\n#30DayChartChallenge 2022 #Day25 - Trend\nDataViz: Federica Gazzelloni | Twitter: @fgazzelloni",
       x="YEAR",y="Temperature Anomaly (C)\n")+
  theme_linedraw()+
  theme(text = element_text(color="grey60"),
        plot.caption = element_text(hjust=0,color="grey40"),
        plot.caption.position = "plot",
        plot.title = element_text(color="#c15a4f",face="bold",size=17),
        plot.title.position = "plot",
        plot.subtitle = element_text(color="grey40",size=13,vjust=-2),
        panel.border = element_rect(fill=NA,size=0.5,color="#e2e2e2"),
        panel.grid.major = element_line(color="grey60",size=0.3),
        panel.grid.minor.y = element_blank(),
        panel.grid.minor.x = element_blank(),
        axis.title.x = element_text(color="grey40",hjust=0.45,vjust=-1.5),
        axis.text.x = element_text(size=11.5,color="grey30",vjust=-0.5),
        axis.text.y.left = element_text(size=11.5,color="grey30"),
        axis.text.y.right = element_blank(),
        axis.title.y.left = element_text(color="grey40"),
        axis.title.y.right = element_blank(),
        axis.line.y.right  = element_line(color = 'white'),
        axis.ticks = element_blank(),
        plot.margin = margin(20,20,10,20,unit = "pt"))+
  # double rects-----
  annotate("rect", xmin = 1881.5, xmax = 1884.5, 
           ymin = 1.3, ymax = 1.4,
           alpha = .9,color="grey70",size=0.9,fill="grey70") +
  # grey square
  annotate("rect", xmin = 1881.5, xmax = 1884.5, 
           ymin = 1.3, ymax = 1.4,size=0.3,
           alpha = .9,color="white",fill="grey70") +
  
  annotate("rect", xmin = 1881.5, xmax = 1884.5, 
           ymin = 1.13, ymax = 1.23,
           alpha = .9,color="grey70",size=0.9,fill="grey70")+
  # black square
  annotate("rect", xmin = 1881.5, xmax = 1884.5, 
           ymin = 1.13, ymax = 1.23,
           alpha = .9,color="white",size=0.3,fill="black")+
  

  # legend labels
  annotate("label",x=1897.46,y=1.35,
           label="Annual mean", size=5,
           label.padding = unit(0.05, "lines"), 
           label.size = NA) +
  annotate("label",x=1902,y=1.18,
           label="Lowess smoothing",size=5,
           label.size = NA,
           label.padding = unit(0.05, "lines"))
ggsave("test.png",
       dpi=320,
       width = 8,
       height = 5)

SPECIAL PALEOTEMPS———-

All_palaeotemps <- readxl::read_excel("/Users/federica/Documents/R/R_general_resources/EDA/30DayChartChallenge/data/Edition_2022/day25_trend/All_palaeotemps.xlsx", 
    sheet = "Data compilation", skip = 2)
df1 <- All_palaeotemps%>%
  janitor::clean_names()%>%
  select(age1=age_my_1,
         temp1=royer_veizer_x_2_0,
         temp2=royer_veizer_co2_from_proxies_x_2_0,
         low,high,
         age2=age_my_8,
         t_anomaly=t_anomaly_13)

df2 <- All_palaeotemps%>%
  janitor::clean_names()%>%
  select(age1=age_my_1,
         temp1=royer_veizer_x_2_0,
         temp2=royer_veizer_co2_from_proxies_x_2_0,
         low,high,
         age2=age_my_8,
         t_anomaly=t_anomaly_13)%>%
  pivot_longer(cols = c(age1,age2),names_to="ages",values_to="age_val")%>%
  pivot_longer(cols=c(temp1,temp2,low,high,t_anomaly),names_to="temps",values_to="temp_val")
  

df1
ggplot(df2,aes(x=(age_val),y=temp_val,group=factor(temps),color=factor(temps)))+
  geom_line()+
  scale_x_reverse()
# df1$royer_veizer_x_2_0[is.na(df1$royer_veizer_x_2_0)]<-0

ggplot(df1,aes(x=age1,y=low))+
  #geom_point()+
  #geom_smooth(size=0.01)+
  geom_line(inherit.aes = T,
            size=0.5,
            #alpha=0.5,
            color="gold")+
  #geom_line(aes(x=age_my_1-10,y=low+2),
  #         inherit.aes = T,
  #         size=0.5,
  #         #alpha=0.5,
  #         color="gold")+
  geom_ribbon(aes(xmin=age1,
                  xmax=age1,
                  ymin=low,
                 ymax=low+3),
              fill="gold")+
 # geom_ribbon(aes(xmin=age_my_1,
 #                 xmax=age_my_1-10,
 #                 ymin=low,
 #                 ymax=low+2))+
  # geom_line(aes(y=high),
  #           inherit.aes = T,
  #           size=1,
  #           alpha=0.5,
  #           color="orange")+
    geom_line(aes(y=temp1),
            inherit.aes = T,
            size=0.8,
            color="red")+
  geom_line(aes(y=temp2),
            inherit.aes = T,
            color="black",
            size=0.8,
            linetype="dashed")+
  geom_hline(aes(yintercept=0))+
  scale_x_reverse(breaks=c(500,400,300,200,100))+
  geom_line(aes(x=age2,y=t_anomaly),color="darkgreen")+
  theme_bw()