library(dplyr)
library(data.table)
library(stringr)
library(tidyverse)
library(lubridate)
library(RColorBrewer)
library(plotly)
Warming Stripes
Required libraries
Pre-processing
<- fread("https://data.giss.nasa.gov/gistemp/tabledata_v4/GLB.Ts+dSST.csv") %>%
warm_strip mutate(`J-D` = as.numeric(str_replace(`J-D`, pattern = "-.", replacement = "-0."))) %>%
mutate(Year = ymd(Year, truncated = 2L))
<- warm_strip[1:(nrow(warm_strip)-1),] warm_strip
Preparing theme
<- theme_minimal()+
theme_strip 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")
)
<- brewer.pal(11, "RdBu") col_strip
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()