October 1, 2024
Grab country shapes with ne_countries()
Make a map using geom_sf()
from ggplot2
.
Add a color scale and a theme.
geom_sf()
to make the map05:00
Grab data from the WB, join with country shapes…
ggplot(data = rents_map_df) +
geom_sf(aes(fill = oil_rents_gdp)) + # shade based on oil rents
labs(
title = "Oil rents (% of GDP)",
subtitle = "(Most recent available data)", # add subtitle
fill = "Percent",
caption = "Source: World Bank Development Indicators"
) +
theme_map() +
theme(
legend.position = "right",
#legend.title = element_text(size = 8),
#legend.text = element_text(size = 6)
plot.title = element_text(face = "bold"), # move legend
) +
scale_fill_viridis_c( # chg from discrete (_d) to continuous (_c)
option = "magma", # chg to magma theme
labels = scales::label_percent(scale = 1) # add % label for legend
)
wbstats
geom_sf()
10:00
10:00
10:00