if (interactive()) {
trade_by_continent <- d3po::trade[d3po::trade$year == 2023L, ]
trade_by_continent <- aggregate(
trade ~ reporter_continent,
data = d3po::trade,
FUN = sum
)
# Assign colors to continents
# my_pal <- tintin::tintin_pal(option = "The Black Island")(7)
# [1] "#175CA1" "#435C88" "#478CB3" "#6D8798" "#8D4B56" "#8D817B" "#B68563"
my_pal <- c("#175CA1", "#435C88", "#478CB3", "#6D8798", "#8D4B56", "#8D817B", "#B68563")
names(my_pal) <- c(
"Africa", "Antarctica", "Asia",
"Europe", "North America", "Oceania", "South America"
)
d3po(trade_by_continent, width = 800, height = 600) %>%
po_pie(daes(size = trade, group = reporter_continent, color = my_pal)) %>%
po_labels(title = "Trade Share by Reporter Continent in 2023")
}
Run the code above in your browser using DataLab