library(ipeadatar)
library(ggplot2)
library(dplyr)
library(geobr)
library(jsonlite)
cp <- read.csv("https://ourworldindata.org/grapher/sugar-cane-production.csv?v=1&csvType=full&useColumnShortNames=true")
cp_metadata <- fromJSON("https://ourworldindata.org/grapher/sugar-cane-production.metadata.json?v=1&csvType=full&useColumnShortNames=true")
Criei então o cp (cana países).
Filtre um ano e olhe quais os principais produtores.
cp2 <- cp %>% filter(Code %in% c("BRA", "IND", "CHN", "THA"))
Fazendo um gráfico bonito o suficiente:
cp2$producao <- cp2$sugar_cane__00000156__production__005510__tonnes
ggplot(cp2, aes(x = Year,
y = producao / 1e6,
group = Entity,
color = Entity)) +
geom_line(linewidth = 1) +
geom_point(aes(shape = Entity), size = 2) +
scale_color_manual(values = c("Brazil" = "darkgreen",
"China" = "darkred",
"India" = "darkorange",
"Thailand" = "black")) +
scale_shape_manual(values = c("Brazil" = 16, # filled circle
"China" = 17, # filled triangle
"India" = 15, # filled square
"Thailand" = 18)) + # filled diamond
labs(title = "",
y = "Production (million tonnes)",
color = "",
shape = "", x = "") +
theme_minimal() +
theme(legend.position = "bottom",
plot.title = element_text(hjust = 0.5))
Será que fica bom colocar uma indicação da política de
biocombustíveis no Brasil?
ggplot(cp2, aes(x = Year,
y = producao / 1e6,
group = Entity,
color = Entity)) +
geom_line(linewidth = 1) +
geom_point(aes(shape = Entity), size = 2) +
scale_color_manual(values = c("Brazil" = "darkgreen",
"China" = "darkred",
"India" = "darkorange",
"Thailand" = "black")) +
scale_shape_manual(values = c("Brazil" = 16, # filled circle
"China" = 17, # filled triangle
"India" = 15, # filled square
"Thailand" = 18)) + # filled diamond
# Linha vertical em 2003 (dashed, darkgreen)
geom_vline(xintercept = 2003, linetype = "dashed", color = "darkgreen", linewidth = 0.5) +
# Seta apontando para a linha (com yend = y para manter a seta horizontal)
annotate("segment",
x = 2001, xend = 2002.9,
y = max(cp2$producao / 1e6) * 0.85, yend = max(cp2$producao / 1e6) * 0.85,
color = "darkgreen",
arrow = arrow(type = "closed", length = unit(0.2, "cm"))) +
# Texto da política de biocombustíveis
annotate("text",
x = 1978,
y = max(cp2$producao / 1e6) * 0.85,
label = "Biofuels policy in Brazil",
color = "darkgreen",
hjust = 0, size = 3.5, fontface = "bold") +
labs(y = "Production (million tonnes)",
color = "", shape = "", x = "") +
theme_minimal() +
theme(legend.position = "bottom",
plot.title = element_text(hjust = 0.5))