All data comes from the TidyTuesday 2021 Week 15 collection, originally sourced from the UN Food and Agriculture Organization (FAO) and Global Forest Watch (GFW). Place all five CSV files in the same folder as this .Rmd before knitting.
forest <- read_csv("forest.csv")
forest_area <- read_csv("forest_area.csv")
brazil_loss <- read_csv("brazil_loss.csv")
soybean_use <- read_csv("soybean_use.csv")
vegetable_oil <- read_csv("vegetable_oil.csv")
fig1_dat <- forest %>%
filter(year == 2000,
!entity %in% c("World","Africa","Asia","Europe",
"North America","South America","Oceania"),
!is.na(net_forest_conversion)) %>%
slice_min(order_by = net_forest_conversion, n = 10) %>%
mutate(entity = fct_reorder(entity, net_forest_conversion))
ggplot(fig1_dat, aes(x = net_forest_conversion / 1000, y = entity, fill = net_forest_conversion)) +
geom_col(show.legend = FALSE) +
scale_fill_gradient(low = "#8B0000", high = "#F4A460") +
scale_x_continuous(labels = comma) +
labs(
title = "Top 10 Countries with the Greatest Net Forest Loss in 2000",
subtitle = "Net forest conversion in thousands of hectares (negative = net loss)",
x = "Net Forest Conversion (thousands of hectares)",
y = "Country",
caption = "Source: UN FAO via TidyTuesday 2021"
) +
theme_minimal(base_size = 13) +
theme(
plot.title = element_text(face = "bold", size = 14),
plot.subtitle = element_text(color = "gray40"),
panel.grid.major.y = element_blank()
)
countries_sel <- c("Brazil", "Indonesia", "Nigeria", "Australia", "Russia")
fig2_dat <- forest_area %>%
filter(entity %in% countries_sel)
ggplot(fig2_dat, aes(x = year, y = forest_area, color = entity)) +
geom_line(linewidth = 1.2) +
geom_point(size = 1.5) +
scale_color_brewer(palette = "Set1") +
scale_y_continuous(labels = function(x) paste0(round(x, 1), "%")) +
labs(
title = "Forest Area as a Percentage of Land Area (1990–2020)",
subtitle = "Tracking long-term deforestation trends in five major forested nations",
x = "Year",
y = "Forest Area (% of land area)",
color = "Country",
caption = "Source: UN FAO via TidyTuesday 2021"
) +
theme_minimal(base_size = 13) +
theme(
plot.title = element_text(face = "bold", size = 14),
plot.subtitle = element_text(color = "gray40"),
legend.position = "right"
)
fig3_dat <- brazil_loss %>%
select(year, pasture, commercial_crops, small_scale_clearing,
selective_logging, fire, other_infrastructure) %>%
pivot_longer(-year, names_to = "driver", values_to = "loss_ha") %>%
mutate(driver = str_replace_all(driver, "_", " "),
driver = str_to_title(driver),
loss_ha = loss_ha / 1000)
ggplot(fig3_dat, aes(x = factor(year), y = loss_ha, fill = driver)) +
geom_col() +
scale_fill_brewer(palette = "Set2") +
labs(
title = "Annual Forest Loss in Brazil by Driver (2001–2013)",
subtitle = "Pasture clearing dominates as the primary cause of Amazon deforestation",
x = "Year",
y = "Forest Loss (thousands of hectares)",
fill = "Driver",
caption = "Source: Global Forest Watch via TidyTuesday 2021"
) +
theme_minimal(base_size = 13) +
theme(
plot.title = element_text(face = "bold", size = 14),
plot.subtitle = element_text(color = "gray40"),
axis.text.x = element_text(angle = 45, hjust = 1)
)
fig4_dat <- forest %>%
filter(year %in% c(1990, 2015),
!entity %in% c("World","Africa","Asia","Europe",
"North America","South America","Oceania"),
!is.na(net_forest_conversion)) %>%
pivot_wider(names_from = year, values_from = net_forest_conversion,
names_prefix = "y") %>%
filter(!is.na(y1990), !is.na(y2015)) %>%
mutate(change = y2015 - y1990) %>%
slice_min(order_by = change, n = 12) %>%
mutate(entity = fct_reorder(entity, change))
ggplot(fig4_dat) +
geom_segment(aes(x = y1990 / 1000, xend = y2015 / 1000,
y = entity, yend = entity),
color = "gray70", linewidth = 1) +
geom_point(aes(x = y1990 / 1000, y = entity), color = "#2166ac", size = 3.5) +
geom_point(aes(x = y2015 / 1000, y = entity), color = "#d6604d", size = 3.5) +
annotate("text", x = -4600, y = 12.5, label = "1990", color = "#2166ac",
fontface = "bold", size = 4) +
annotate("text", x = -4200, y = 12.5, label = "2015", color = "#d6604d",
fontface = "bold", size = 4) +
scale_x_continuous(labels = comma) +
labs(
title = "Change in Net Forest Conversion: 1990 vs 2015",
subtitle = "Blue = 1990 | Red = 2015 | Countries with greatest worsening shown",
x = "Net Forest Conversion (thousands of hectares)",
y = "Country",
caption = "Source: UN FAO via TidyTuesday 2021"
) +
theme_minimal(base_size = 13) +
theme(
plot.title = element_text(face = "bold", size = 14),
plot.subtitle = element_text(color = "gray40"),
panel.grid.major.y = element_blank()
)
fig5_dat <- brazil_loss %>%
select(year, pasture, commercial_crops, small_scale_clearing,
selective_logging, fire, other_infrastructure, roads, mining) %>%
pivot_longer(-year, names_to = "driver", values_to = "loss_ha") %>%
mutate(driver = str_replace_all(driver, "_", " "),
driver = str_to_title(driver))
ggplot(fig5_dat, aes(x = factor(year), y = driver, fill = loss_ha / 1000)) +
geom_tile(color = "white", linewidth = 0.5) +
scale_fill_distiller(palette = "YlOrRd", direction = 1,
labels = comma,
name = "Loss\n(000s ha)") +
labs(
title = "Heatmap of Brazil Forest Loss by Driver and Year (2001–2013)",
subtitle = "Darker color = greater forest loss in that category",
x = "Year",
y = "Deforestation Driver",
caption = "Source: Global Forest Watch via TidyTuesday 2021"
) +
theme_minimal(base_size = 13) +
theme(
plot.title = element_text(face = "bold", size = 14),
plot.subtitle = element_text(color = "gray40"),
axis.text.x = element_text(angle = 45, hjust = 1),
panel.grid = element_blank()
)
fig6_dat <- soybean_use %>%
filter(entity == "Brazil", !is.na(human_food)) %>%
pivot_longer(c(human_food, animal_feed, processed),
names_to = "use_type", values_to = "tonnes") %>%
mutate(use_type = case_when(
use_type == "human_food" ~ "Human Food",
use_type == "animal_feed" ~ "Animal Feed",
use_type == "processed" ~ "Processed"
))
ggplot(fig6_dat, aes(x = year, y = tonnes / 1e6, fill = use_type)) +
geom_area(alpha = 0.85) +
scale_fill_manual(values = c("#66c2a5", "#fc8d62", "#8da0cb")) +
scale_y_continuous(labels = function(x) paste0(x, "M t")) +
labs(
title = "Soybean Use in Brazil by Category (1961–2013)",
subtitle = "Soy expansion for animal feed is a key indirect driver of deforestation",
x = "Year",
y = "Soybeans (millions of tonnes)",
fill = "Use Type",
caption = "Source: UN FAO via TidyTuesday 2021"
) +
theme_minimal(base_size = 13) +
theme(
plot.title = element_text(face = "bold", size = 14),
plot.subtitle = element_text(color = "gray40")
)
fig7_dat <- forest_area %>%
filter(entity %in% c("Brazil", "Indonesia", "Nigeria", "Australia", "Russia"),
year >= 1992)
p7 <- plot_ly(fig7_dat,
x = ~year,
y = ~round(forest_area, 2),
color = ~entity,
colors = RColorBrewer::brewer.pal(5, "Set1"),
type = "scatter",
mode = "lines+markers",
hovertemplate = paste("<b>%{fullData.name}</b><br>",
"Year: %{x}<br>",
"Forest Area: %{y}%<extra></extra>")) %>%
layout(
title = list(text = "Interactive: Forest Area Over Time (1992–2020)<br><sup>Hover over lines for exact values. Click legend to show/hide countries.</sup>",
font = list(size = 14)),
xaxis = list(title = "Year"),
yaxis = list(title = "Forest Area (% of land area)",
ticksuffix = "%"),
legend = list(title = list(text = "Country")),
hovermode = "x unified"
)
p7
fig8_dat <- forest %>%
filter(year == 2015,
!entity %in% c("World","Africa","Asia","Europe",
"North America","South America","Oceania"),
!is.na(net_forest_conversion)) %>%
arrange(net_forest_conversion) %>%
head(20) %>%
mutate(entity = fct_reorder(entity, net_forest_conversion),
color = ifelse(net_forest_conversion < 0, "#d6604d", "#4dac26"))
p <- ggplot(fig8_dat,
aes(x = net_forest_conversion / 1000, y = entity,
text = paste0(entity, "\n",
round(net_forest_conversion / 1000, 1),
"k ha"))) +
geom_col(fill = "#d6604d") +
scale_x_continuous(labels = comma) +
labs(
title = "Net Forest Conversion in 2015 — Bottom 20 Countries (Interactive)",
x = "Net Forest Conversion (thousands of hectares)",
y = "Country",
caption = "Source: UN FAO via TidyTuesday 2021"
) +
theme_minimal(base_size = 12) +
theme(
plot.title = element_text(face = "bold"),
panel.grid.major.y = element_blank()
)
ggplotly(p, tooltip = "text") %>%
layout(title = list(
text = "Net Forest Conversion in 2015 — Bottom 20 Countries<br><sup>Hover over bars for exact values</sup>"
))
All figures created in R using ggplot2, plotly, and gganimate. Data sourced from the UN FAO and Global Forest Watch via TidyTuesday Week 15, 2021.