Algumas Ilustrações

Pacotes usados

Se o library("nomedopacote") não funcionar, talvez você não tenha instalado o pacote ainda. Por isso, talvez você precise utilizar o install.packages("nomedopacote") antes. Este procedimento de instalar algo precisa ser feito apenas uma vez, mas o carregamento do pacote, library("nomedopacote") precisa ser feito toda vez que você abrir o Rstudio.

Se algum pacote não rodar:
install.packages(“nome do pacote que nao rodou”)

Já esta parte aqui você precisa fazer TODA VEZ QUE INICIAR UMA NOVA SESSÃO:

library("ipeadatar")
library("ggplot2")
library("ggthemes")
library("sidrar")
library("tidyr")
library("tidyverse")
library("wbstats")
library("geobr")
library("sp")
library("sf")
library("jsonlite")

As bases de dados usadas aqui são públicas e eu não preciso enviá-las para vocês. A gente faz o download delas de três fontes preferencialmente:

  • IPEADATA com o library("ipeadatar")

  • Our World in Data com o read.csv combinado com library("jsonlite")

  • Dados do IBGE pelo library("sidrar")

Isso facilita a vida porque você não vai se preocupar com criar as bases, nem se a base está separada por vírgulas, por pontos, etc. A parte ruim é que você não vai aprender a lidar com esses problemas básicos logo no início.

CO2 e PIB

library(jsonlite)

# Fetch the data
co2 <- read.csv("https://ourworldindata.org/grapher/co2-emissions-vs-gdp.csv?v=1&csvType=full&useColumnShortNames=true")

# Fetch the metadata
metadata <- fromJSON("https://ourworldindata.org/grapher/co2-emissions-vs-gdp.metadata.json?v=1&csvType=full&useColumnShortNames=true")

O gráfico usado na aula

library(ggplot2)
library(dplyr)

# Filtrar apenas o ano de 2022
dados_2022 <- co2 %>% filter(Year == 2022)

# Criar variáveis para destacar o Brasil
dados_2022 <- dados_2022 %>%
  mutate(tamanho_ponto = ifelse(Entity == "Brazil", 3, 2),
         cor_ponto     = ifelse(Entity == "Brazil", "red", "darkblue"))

# Criar o gráfico
ggplot(dados_2022, aes(x = gdp_per_capita, y = emissions_total_per_capita)) +
  geom_point(aes(size = tamanho_ponto, color = cor_ponto),
             alpha = 0.7) +
  geom_smooth(method = "lm", se = FALSE, color = "black", linetype = "dashed") +
  scale_size_identity() +        # Usa valores numéricos diretamente
  scale_color_identity() +       # Usa cores diretamente
  labs(title = "Relação entre PIB per capita e Emissões de CO2 per capita (2022)",
       x = "PIB per capita",
       y = "Emissões totais de CO2 per capita",
       caption = "Fonte: Ourworldindata") +
  theme_minimal() +
  theme(
    legend.position = "none",
    axis.title = element_text(size = 14),  # aumenta títulos dos eixos
    axis.text  = element_text(size = 12)   # aumenta números dos eixos
  )
## `geom_smooth()` using formula = 'y ~ x'
## Warning: Removed 109 rows containing non-finite outside the scale range
## (`stat_smooth()`).
## Warning: Removed 109 rows containing missing values or values outside the scale range
## (`geom_point()`).

ggsave("eru482_1.png", 
       plot = last_plot(),
       width = 8, height = 6, dpi = 300)
## `geom_smooth()` using formula = 'y ~ x'
## Warning: Removed 109 rows containing non-finite outside the scale range
## (`stat_smooth()`).
## Removed 109 rows containing missing values or values outside the scale range
## (`geom_point()`).
# Criar o gráfico
ggplot(dados_2022, aes(x = log(gdp_per_capita), y = log(emissions_total_per_capita))) +
  geom_point(aes(size = tamanho_ponto, color = cor_ponto),
             alpha = 0.7) +
  geom_smooth(method = "lm", se = FALSE, color = "darkgreen", linetype = "dashed") +
  scale_size_identity() +        # Usa valores numéricos diretamente
  scale_color_identity() +       # Usa cores diretamente
  labs(title = "Relação entre PIB per capita e Emissões de CO2 per capita (2022)",
       x = "PIB per capita (log)",
       y = "Emissões totais de CO2 per capita (log)",
       caption = "Fonte: Ourworldindata") +
  theme_minimal() +
  theme(
    legend.position = "none",
    axis.title = element_text(size = 14),  # aumenta títulos dos eixos
    axis.text  = element_text(size = 12)   # aumenta números dos eixos
  )
## `geom_smooth()` using formula = 'y ~ x'
## Warning: Removed 109 rows containing non-finite outside the scale range
## (`stat_smooth()`).
## Warning: Removed 109 rows containing missing values or values outside the scale range
## (`geom_point()`).

ggsave("eru482_2.png", 
       plot = last_plot(),
       width = 8, height = 6, dpi = 300)
## `geom_smooth()` using formula = 'y ~ x'
## Warning: Removed 109 rows containing non-finite outside the scale range
## (`stat_smooth()`).
## Removed 109 rows containing missing values or values outside the scale range
## (`geom_point()`).

Voos

library(flightsbr)
voo <- flightsbr::read_airfares(date = 202412, domestic = TRUE)
voo2 <- flightsbr::read_airfares(date = 202409, domestic = TRUE)

Vou filtrar só os voos de BH para Salvador.

bh<-voo %>% filter(destino=="SBSV") %>% filter(origem=="SBCF")
bh2<-voo2%>% filter(destino=="SBSV") %>% filter(origem=="SBCF")

bhtd<-rbind(bh, bh2)
library(ggplot2)

# Calcular a moda da distribuição ponderada
densidade <- density(bh$tarifa, weights = bh$assentos/sum(bh$assentos))
moda <- densidade$x[which.max(densidade$y)]

ggplot(bh, aes(x = tarifa, weight = assentos)) +
  geom_density(fill = "lightblue", alpha = 0.7) +
  geom_vline(xintercept = moda, color = "black", linetype = "dashed", size = 1) +
  annotate("text", x = moda, y = 0.1*max(densidade$y), 
           label = paste("Moda: R$", round(moda, 0)), 
           vjust = -1, hjust = -0.1, color = "black", size = 4) +
  labs(title = "Tarifas BHZ->SSA em dezembro-2024",
       x = "Tarifa (R$)",
       y = "Densidade") +
  theme_minimal()


ggsave("eru482_3.png", 
       plot = last_plot(),
       width = 8, height = 6, dpi = 300)
v1<- flightsbr::read_airfares(date = 2024, domestic = TRUE)
v2 <- v1 %>%  filter(destino=="SBSV") %>% filter(origem=="SBCF")

library(ggplot2)
library(dplyr)


tarifa_ponderada <- v2 %>%
  group_by(mes) %>%
  summarise(tarifa_pond = weighted.mean(tarifa, assentos, na.rm = TRUE))

ggplot(tarifa_ponderada, aes(x = as.factor(mes), y = tarifa_pond)) +
  geom_col(fill = "coral", alpha = 0.8) +
  geom_text(aes(label = paste("R$", round(tarifa_pond, 2))), 
            vjust = -0.5, size = 4, color = "black") +
  labs(title = "BHZ->SSA em 2024",
       subtitle = "",
       x = "Mês",
       y = "") +
  theme_minimal()

ggsave("eru482_4.png", 
       plot = last_plot(),
       width = 8, height = 6, dpi = 300)
v3 <- v1 %>% 
  filter(destino == "SBSV",
         origem %in% c("SBRJ", "SBGL"))

library(ggplot2)
library(dplyr)


tarifa_ponderada <- v3 %>%
  group_by(mes) %>%
  summarise(tarifa_pond = weighted.mean(tarifa, assentos, na.rm = TRUE))

ggplot(tarifa_ponderada, aes(x = as.factor(mes), y = tarifa_pond)) +
  geom_col(fill = "lightblue", alpha = 0.8) +
  geom_text(aes(label = paste("R$", round(tarifa_pond, 2))), 
            vjust = -0.5, size = 4, color = "black") +
  labs(title = "Rio->SSA em 2024",
       subtitle = "",
       x = "Mês",
       y = "") +
  theme_minimal()

ggsave("eru482_5.png", 
       plot = last_plot(),
       width = 8, height = 6, dpi = 300)

Emissões - Aula do dia 09 de setembro de 2025

e1 <- read.csv("https://ourworldindata.org/grapher/temperature-anomaly.csv?v=1&csvType=full&useColumnShortNames=true")

e1_metadata <- fromJSON("https://ourworldindata.org/grapher/temperature-anomaly.metadata.json?v=1&csvType=full&useColumnShortNames=true")
library(ggplot2)
library(dplyr)

# Filtrar apenas os dados do Mundo
world_data <- e1 %>% filter(Entity == "World")

# Criar o gráfico com área sombreada
emissoes1 <- ggplot(world_data, aes(x = Year, y = near_surface_temperature_anomaly)) +
  # Área sombreada para os limites inferior e superior
  geom_ribbon(aes(ymin = near_surface_temperature_anomaly_lower, 
                  ymax = near_surface_temperature_anomaly_upper), 
              fill = "lightcoral", alpha = 0.4) +
  # Linha da anomalia de temperatura
  geom_line(color = "darkred", linewidth = 0.7) +
  #geom_point(color = "darkred", size = 1.5) +
  labs(title = "Anomalia de Temperatura Global (1850-2025)",
       subtitle = "Área sombreada: intervalo de incerteza (limites inferior e superior) \n Fonte: Ourworldindata, modificações de Leonardo Cardoso",
       x = "",
       y = "Anomalia de Temperatura (°C)") +
  theme_minimal() +
  theme(plot.title = element_text(hjust = 0.5, size = 14, face = "bold"),
        plot.subtitle = element_text(hjust = 0.5, size = 10),
        axis.title = element_text(size = 12),
        axis.text = element_text(size = 10))

# Mostrar o gráfico
print(emissoes1)

# Salvar como PNG
ggsave("emissoes1.png", plot = last_plot(), width = 10, height = 6, dpi = 300)
hemisphere_data <- e1 %>% filter(Entity != "World")

hemisphere_plot <- ggplot(hemisphere_data, aes(x = Year)) +
  # Área sombreada para Hemisfério Norte
  geom_ribbon(data = filter(hemisphere_data, Entity == "Northern Hemisphere"),
              aes(ymin = near_surface_temperature_anomaly_lower, 
                  ymax = near_surface_temperature_anomaly_upper),
              fill = "lightblue", alpha = 0.4) +
  # Área sombreada para Hemisfério Sul
  geom_ribbon(data = filter(hemisphere_data, Entity == "Southern hemisphere"),
              aes(ymin = near_surface_temperature_anomaly_lower, 
                  ymax = near_surface_temperature_anomaly_upper),
              fill = "lightcoral", alpha = 0.4) +
  # Linhas para cada hemisfério
  geom_line(aes(y = near_surface_temperature_anomaly, color = Entity), linewidth = 1) +
  labs(title = "",
       subtitle = "Anomalias na temperatura (por hemisfério) \n Fonte: Ourworldindata, modificações de Leonardo Cardoso",
       x = "", 
       y = "Anomalia de Temperatura (°C)",
       color = "") +
  scale_color_manual(values = c("Northern Hemisphere" = "blue", 
                               "Southern hemisphere" = "red"),
                     labels = c("Northern Hemisphere" = "Norte", 
                               "Southern hemisphere" = "Sul")) +
  theme_minimal() +
  theme(plot.title = element_text(hjust = 0.5),
        plot.subtitle = element_text(hjust = 0.5),
        legend.position = "bottom")

print(hemisphere_plot)

ggsave("emissoes2.png", plot = last_plot(), width = 7, height = 4, dpi = 300)

Desse aquecimento, quanto é de cada um?

Esses dados eu baixei do base dos dados.
Para esse não tinha o download automático.

dm <- read.csv("contribution-temp-rise-degrees.csv")
library(ggplot2)
library(dplyr)
library(scales)
## Warning: package 'scales' was built under R version 4.3.3
## 
## Attaching package: 'scales'
## The following object is masked from 'package:purrr':
## 
##     discard
## The following object is masked from 'package:readr':
## 
##     col_factor
# Filtrar dados para 2020 e apenas países com Code
data_2020 <- dm %>%
  filter(Year == 2023 & !is.na(Code) & Code != "")

# Calcular o total mundial (World) para 2020
world_total <- data_2020 %>%
  filter(Entity == "World") %>%
  pull(Change.in.global.mean.surface.temperature.caused.by.greenhouse.gas.emissions)

# Calcular o share (percentual) de cada país
data_2020 <- data_2020 %>%
  filter(Entity != "World") %>%
  mutate(Share = Change.in.global.mean.surface.temperature.caused.by.greenhouse.gas.emissions / world_total * 100)

# Selecionar os top 7 maiores contribuidores
top_7 <- data_2020 %>%
  arrange(desc(Change.in.global.mean.surface.temperature.caused.by.greenhouse.gas.emissions)) %>%
  head(7)

# Ordenar por Change (descendente) para o gráfico
top_7 <- top_7 %>%
  mutate(Entity = factor(Entity, levels = Entity[order(Change.in.global.mean.surface.temperature.caused.by.greenhouse.gas.emissions, decreasing = TRUE)]))

# Criar o gráfico de colunas
ggplot(top_7, aes(x = reorder(Entity, -Change.in.global.mean.surface.temperature.caused.by.greenhouse.gas.emissions), 
                  y = Change.in.global.mean.surface.temperature.caused.by.greenhouse.gas.emissions,
                  fill = Entity)) +
  geom_col(show.legend = FALSE) +
  geom_text(aes(label = paste0(round(Share, 1), "%")), 
            vjust = -0.5, size = 4, fontface = "bold") +
  geom_text(aes(label = format(Change.in.global.mean.surface.temperature.caused.by.greenhouse.gas.emissions, 
                              scientific = FALSE, digits = 4)),
            vjust = 1.5, size = 3.5, color = "white", fontface = "bold") +
  labs(title = "7 maiores causadores (1850-2023)",
       subtitle = "",
       x = "",
       y = "Change in Global Mean Surface Temperature (°C)",
       caption = "Fonte: contribution-temp-rise-degrees.csv (Leonardo Cardoso)") +
  scale_y_continuous(expand = expansion(mult = c(0, 0.1))) +
  theme_minimal() +
  theme(plot.title = element_text(hjust = 0.5, size = 16, face = "bold"),
        plot.subtitle = element_text(hjust = 0.5, size = 12),
        axis.text.x = element_text(angle = 0, hjust = 0.5, size = 11),
        axis.title.y = element_text(size = 12),
        plot.caption = element_text(hjust = 1, size = 10),
        panel.grid.major = element_line(color = "gray90"),
        panel.grid.minor = element_blank())

# Salvar o gráfico
ggsave("emissoes4.png", width = 8, height = 6, dpi = 300)

Mas se a gente tirar Land Use (desmatamento sai)

library(jsonlite)

# Fetch the data
e2 <- read.csv("https://ourworldindata.org/grapher/annual-share-of-co2-emissions.csv?v=1&csvType=full&useColumnShortNames=true")

# Fetch the metadata
e2metadata <- fromJSON("https://ourworldindata.org/grapher/annual-share-of-co2-emissions.metadata.json?v=1&csvType=full&useColumnShortNames=true")
library(ggplot2)
library(dplyr)
library(scales)

# Lista de países selecionados
selected_countries <- c("CHN", "USA", "IND", "RUS", "JPN", "IRN", "SAU", "IDN", "DEU", "KOR", "BRA", "MEX")

# Filtrar dados para 2023 e países selecionados
data_2023 <- e2 %>%
  filter(Year == 2023 & Code %in% selected_countries)

# Ordenar os países pela contribuição (descendente)
data_2023 <- data_2023 %>%
  arrange(desc(emissions_total_as_share_of_global)) %>%
  mutate(Entity = factor(Entity, levels = rev(Entity)))

# Criar gráfico de barras HORIZONTAIS
ggplot(data_2023, aes(x = emissions_total_as_share_of_global, 
                     y = reorder(Entity, emissions_total_as_share_of_global),
                     fill = Entity)) +
  geom_col(show.legend = FALSE) +
  geom_text(aes(label = paste0(round(emissions_total_as_share_of_global, 1), "%")), 
            hjust = -0.1, size = 4, fontface = "bold") +
  labs(title = "",
       subtitle = "Emissões de combustíveis fósseis e indústria (2023) \n  Mudanças no uso da terra não estão incluídas.",
       x = "Participação nas Emissões Globais",
       y = "",
       caption = "Fonte: Our World in Data \n Modificações: Leonardo Cardoso") +
scale_x_continuous(labels = function(x) paste0(round(x * 1, 1), "%"),
                     expand = expansion(mult = c(0, 0.2))) +
  scale_fill_brewer(palette = "Paired") +
  theme_minimal() +
  theme(plot.title = element_text(hjust = 0.5, size = 16, face = "bold"),
        plot.subtitle = element_text(hjust = 0.5, size = 12),
        axis.text.y = element_text(size = 11, hjust = 1),
        axis.title.x = element_text(size = 12),
        panel.grid.major = element_line(color = "gray90"),
        panel.grid.minor = element_blank())

# Salvar
ggsave("emissoes5.png", width = 8, height = 5, dpi = 300)

Fazendo pela média dos valores

library(ggplot2)
library(dplyr)
library(scales)

# Lista de países selecionados
selected_countries <- c("CHN", "USA", "IND", "RUS", "JPN", "IRN", "SAU", "IDN", "DEU", "KOR", "BRA", "MEX")

# Calcular a média das emissões para cada país (todos os anos disponíveis)
data_mean <- e2 %>%
  filter(Code %in% selected_countries) %>%
  group_by(Entity, Code) %>%
  summarise(mean_emissions_share = mean(emissions_total_as_share_of_global, na.rm = TRUE),
            .groups = "drop")

# Ordenar os países pela contribuição média (descendente)
data_mean <- data_mean %>%
  arrange(desc(mean_emissions_share)) %>%
  mutate(Entity = factor(Entity, levels = rev(Entity)))

# Criar gráfico de barras HORIZONTAIS
ggplot(data_mean, aes(x = mean_emissions_share, 
                     y = reorder(Entity, mean_emissions_share),
                     fill = Entity)) +
  geom_col(show.legend = FALSE) +
  geom_text(aes(label = paste0(round(mean_emissions_share, 1), "%")), 
            hjust = -0.1, size = 4, fontface = "bold") +
  labs(title = "",
       subtitle = "Média das emissões de combustíveis fósseis e indústria \nMudanças no uso da terra não estão incluídas.",
       x = "Participação Média nas Emissões Globais",
       y = "",
       caption = "Fonte: Our World in Data \nModificações: Leonardo Cardoso") +
  scale_x_continuous(labels = function(x) paste0(round(x, 1), "%"),
                     expand = expansion(mult = c(0, 0.2))) +
  scale_fill_brewer(palette = "Paired") +
  theme_minimal() +
  theme(plot.title = element_text(hjust = 0.5, size = 16, face = "bold"),
        plot.subtitle = element_text(hjust = 0.5, size = 12),
        axis.text.y = element_text(size = 11, hjust = 1),
        axis.title.x = element_text(size = 12),
        panel.grid.major = element_line(color = "gray90"),
        panel.grid.minor = element_blank())

# Salvar
ggsave("emissoes6.png", width = 8, height = 5, dpi = 300)
e3 <- read.csv("https://ourworldindata.org/grapher/co-emissions-per-capita.csv?v=1&csvType=full&useColumnShortNames=true")
library(ggplot2)
library(dplyr)
library(scales)

# Lista de países selecionados
selected_countries <- c("CHN", "USA", "IND", "RUS", "JPN", "IRN", "SAU", "IDN", "DEU", "KOR", "BRA", "MEX")

# Calcular a média das emissões per capita para cada país (todos os anos disponíveis)
data_mean_per_capita <- e3 %>%
  filter(Code %in% selected_countries) %>%
  group_by(Entity, Code) %>%
  summarise(mean_emissions_per_capita = mean(emissions_total_per_capita, na.rm = TRUE),
            .groups = "drop")

# Ordenar os países pela emissão per capita média (descendente)
data_mean_per_capita <- data_mean_per_capita %>%
  arrange(desc(mean_emissions_per_capita)) %>%
  mutate(Entity = factor(Entity, levels = rev(Entity)))

# Criar gráfico de barras HORIZONTAIS
ggplot(data_mean_per_capita, aes(x = mean_emissions_per_capita, 
                                y = reorder(Entity, mean_emissions_per_capita),
                                fill = Entity)) +
  geom_col(show.legend = FALSE) +
  geom_text(aes(label = round(mean_emissions_per_capita, 2)), 
            hjust = -0.1, size = 4, fontface = "bold") +
  labs(title = "",
       subtitle = "Média das emissões per capita de combustíveis fósseis e indústria\nMudanças no uso da terra não estão incluídas.",
       x = "Emissões per Capita (toneladas de CO2)",
       y = "",
       caption = "Fonte: Our World in Data \nModificações: Leonardo Cardoso") +
  scale_x_continuous(expand = expansion(mult = c(0, 0.2))) +
  scale_fill_brewer(palette = "Paired") +
  theme_minimal() +
  theme(plot.title = element_text(hjust = 0.5, size = 16, face = "bold"),
        plot.subtitle = element_text(hjust = 0.5, size = 12),
        axis.text.y = element_text(size = 11, hjust = 1),
        axis.title.x = element_text(size = 12),
        panel.grid.major = element_line(color = "gray90"),
        panel.grid.minor = element_blank())

# Salvar
ggsave("emissoes7.png", width = 8, height = 5, dpi = 300)

Percentagem de carros elétricos?

e4 <- read.csv("https://ourworldindata.org/grapher/electric-car-sales-share.csv?v=1&csvType=full&useColumnShortNames=true")
library(ggplot2)
library(dplyr)
library(scales)

# Lista de países/regiões selecionados
selected_entities <- c("Europe", "Brazil", "Norway", "Japan", "Chile", "China", "United States")

# Filtrar dados para 2024 e entidades selecionadas
data_2024 <- e4 %>%
  filter(Year == 2024 & Entity %in% selected_entities)

# Ordenar as entidades pelo percentual de EVs (descendente)
data_2024 <- data_2024 %>%
  arrange(desc(ev_sales_share)) %>%
  mutate(Entity = factor(Entity, levels = rev(Entity)))

# Criar gráfico de barras HORIZONTAIS
ggplot(data_2024, aes(x = ev_sales_share, 
                     y = reorder(Entity, ev_sales_share),
                     fill = Entity)) +
  geom_col(show.legend = FALSE) +
  geom_text(aes(label = paste0(round(ev_sales_share * 1, 1), "%")), 
            hjust = -0.1, size = 4, fontface = "bold") +
  labs(title = "",
       subtitle = "Percentual elétricos dentre os carros novos (2024)",
       x = "",
       y = "",
       caption = "Fonte: Our World in Data \nModificações: Leonardo Cardoso") +
  scale_x_continuous(expand = expansion(mult = c(0, 0.2))) +
  scale_fill_brewer(palette = "Paired") +
  theme_minimal() +
  theme(plot.title = element_text(hjust = 0.5, size = 16, face = "bold"),
        plot.subtitle = element_text(hjust = 0.5, size = 12),
        axis.text.y = element_text(size = 11, hjust = 1),
        axis.title.x = element_text(size = 12),
        panel.grid.major = element_line(color = "gray90"),
        panel.grid.minor = element_blank())

# Salvar
ggsave("emissions8.png", width = 8, height = 5, dpi = 300)
e5 <- read.csv("https://ourworldindata.org/grapher/carbon-footprint-travel-mode.csv?v=1&csvType=full&useColumnShortNames=true")
library(ggplot2)
library(dplyr)
library(scales)

# Filtrar apenas os modos de transporte selecionados
selected_transport <- c("Diesel car", "Petrol car", "Domestic flight", "National rail")

# Traduzir os nomes para português
transport_pt <- data.frame(
  Entity = c("Diesel car", "Petrol car", "Domestic flight", "National rail"),
  Entity_pt = c("Carro a Diesel", "Carro a Gasolina", "Voo Doméstico", "Trem")
)

# Filtrar e traduzir os dados
data_2022 <- e5 %>%
  filter(Year == 2022 & Entity %in% selected_transport) %>%
  left_join(transport_pt, by = "Entity") %>%
  arrange(desc(transport_emissions_factor))

# Criar gráfico de barras VERTICAIS
ggplot(data_2022, aes(x = reorder(Entity_pt, -transport_emissions_factor), 
                     y = transport_emissions_factor,
                     fill = Entity_pt)) +
  geom_col(show.legend = FALSE) +
  geom_text(aes(label = paste0(round(transport_emissions_factor, 0), " g/km")), 
            vjust = -0.5, size = 4, fontface = "bold") +
  labs(title = "",
       subtitle = "Pegada de carbono por quilômetro (2022)\nEmissões de CO2 equivalente por passageiro por km",
       x = "",
       y = "Emissões (g de CO2e por km)",
       caption = "Fonte: Our World in Data \nModificações: Leonardo Cardoso") +
  scale_fill_brewer(palette = "Paired") +
  theme_minimal() +
  theme(plot.title = element_text(hjust = 0.5, size = 16, face = "bold"),
        plot.subtitle = element_text(hjust = 0.5, size = 12),
        axis.text.x = element_text(angle = 0, hjust = 0.5, size = 11),
        axis.title.y = element_text(size = 12),
        panel.grid.major = element_line(color = "gray90"),
        panel.grid.minor = element_blank())

# Salvar
ggsave("emissoes9.png", width = 10, height = 6, dpi = 300)