Joao Lucas Hilgert, M.Sc.
  • Home
  • CV
    • English
    • Deutsch
  • Master Thesis
  • Projects
  • DARK/LIGHT

On this page

  • Warming Stripes
    • Required libraries
    • Pre-processing
    • Preparing theme
    • Downloadable graphic

Warming Stripes


Required libraries

library(dplyr)
library(data.table)
library(stringr)
library(tidyverse)
library(lubridate)
library(RColorBrewer)
library(plotly)

Pre-processing

warm_strip <- fread("https://data.giss.nasa.gov/gistemp/tabledata_v4/GLB.Ts+dSST.csv") %>%
  mutate(`J-D` = as.numeric(str_replace(`J-D`, pattern = "-.", replacement = "-0."))) %>%
  mutate(Year = ymd(Year, truncated = 2L))

warm_strip <- warm_strip[1:(nrow(warm_strip)-1),]

Preparing theme

theme_strip <- theme_minimal()+
  theme(axis.text.y = element_blank(),
        axis.line.y = element_blank(),
        axis.title = element_blank(),
        panel.grid.major = element_blank(),
        legend.title = element_blank(),
        axis.text.x = element_text(vjust = 3),
        panel.grid.minor = element_blank(),
        plot.title = element_text(size = 14, face = "bold")
  )

col_strip <- brewer.pal(11, "RdBu")

Downloadable graphic

ggplot(warm_strip,
       aes(x = Year, y = 1, fill = `J-D`))+
  geom_tile(show.legend = FALSE)+
  scale_x_date(date_breaks = "6 years",
               date_labels = "%Y",
               expand = c(0, 0))+
  scale_y_discrete(expand = c(0, 0))+
  scale_fill_gradientn(colors = rev(col_strip))+
  theme_void()

© Copyright 2022 Joao Lucas D. R. Hilgert. Except where otherwise noted, all text and images licensed CC-BY-NC 4.0. / All flag icons created by Freepik - Flaticon