Last active
November 1, 2021 17:16
-
-
Save leeolney3/c287f21d8ce9c44053428c26446bfb51 to your computer and use it in GitHub Desktop.
TidyTuesday 2021/42
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
library(tidyverse) | |
library(ggtext) | |
library(janitor) | |
stock <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2021/2021-10-12/fish-stocks-within-sustainable-levels.csv') %>% clean_names() | |
theme1 = theme_minimal(base_size = 9, base_family = "Roboto") + | |
theme(legend.position = "top", | |
panel.grid.minor=element_blank(), | |
plot.title=element_text(face="bold", size=14), | |
plot.title.position = "plot", | |
axis.text=element_text(size=6.5), | |
panel.grid=element_line(size=.2), | |
plot.margin = unit(c(.75, 1, .3, .75), "cm"), | |
axis.title=element_text(size=7.5), | |
plot.subtitle=element_text(lineheight = 1.4), | |
plot.caption.position = "plot", | |
plot.caption=element_text(size=6.5, hjust=0, margin=margin(t=8), color="grey10") | |
) | |
stock %>% filter(code=="OWID_WRL") %>% | |
pivot_longer(share_of_fish_stocks_within_biologically_sustainable_levels_fao_2020:share_of_fish_stocks_that_are_overexploited) %>% | |
mutate(value2 = ifelse(name=="share_of_fish_stocks_within_biologically_sustainable_levels_fao_2020",-1*value, value)) %>% | |
ggplot(aes(x=year, y=value2/100, fill=name)) + | |
scale_y_continuous(limits=c(-1,.55), expand=c(0.02,0.02), breaks=seq(-1,.5,0.25), labels=c("100%", "75%", "50%","25%", "0%","25%","50%"), | |
position="right")+ | |
scale_x_continuous(breaks=c(1974,1980,1990, 2000,2010,2017),expand=c(0.03,0.03)) + | |
geom_col(aes(alpha=ifelse(year==1978|year==2017,1,0.55)), show.legend=F) + | |
scale_alpha_identity() + | |
scale_fill_manual(values=c("#c1121f","#3d5a80")) + | |
geom_hline(yintercept = 0) + | |
annotate(geom="text",x=1990, y=-.95, label=("Sustainable share"), | |
color="#3d5a80", size=6, alpha=.8, family="Roboto",hjust=0) + | |
annotate(geom="text",x=1990, y=.45, label=("Overexploited share"), | |
color="#c1121f", size=6, alpha=.8, family="Roboto",hjust=0) + | |
annotate(geom="richtext", label.color=NA, fill=NA,size=2.8, x=2015, y=.53, | |
label="2017: <span style = 'color:#c1121f;'>**34.2%**</span>", family="Roboto") + | |
annotate(geom="richtext", label.color=NA, fill=NA,size=2.8, x=1976.5, y=.35, | |
label="1978: <span style = 'color:#c1121f;'>**8.5%**</span>",, family="Roboto") + | |
annotate(geom="curve", xend=1978, yend=0.1, x=1976.5, y=.32,color="grey70",arrow=arrow(length = unit(0.1, "cm")),curvature = -0.2) + | |
annotate(geom="curve", xend=2017, yend=0.36, x=2015, y=.49,color="grey70",arrow=arrow(length = unit(0.1, "cm")),curvature = -0.2) + | |
theme1 + | |
labs(y="Share of Fish Stocks", x="Year", | |
title=str_to_upper("Increasing pressures on fish populations"), | |
caption="#TidyTuesday Week 42 | Data from OurWorldinData.org", | |
subtitle="More than one-third of global fish stocks are overexploited in 2017.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment