Last active
September 30, 2023 06:36
-
-
Save jimjam-slam/2a832a23dbd07f8021e3c42abb1af0bb to your computer and use it in GitHub Desktop.
ggflags-top10-economics-example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gdp <- data.frame( | |
name = c("us", "cn", "jp", "de", "in", "gb", "fr", "it", "ca"), | |
gdp = c(26854, 19374, 4410, 4309, 3740, 3160, 2924, 2170, 2090), | |
x = c(1,2,3,1,2,3,1,2,3), | |
y = c(3,3,3,2,2,2,1,1,1)) | |
p1 <- ggplot(gdp) + | |
aes(x, y) + | |
geom_flag(aes(country = name, size= gdp)) + | |
geom_text(aes(label = toupper(name)), nudge_y = -0.3, size = 9, | |
family = "Inter", fontface = "bold") + | |
geom_text(aes(label = scales::label_dollar()(gdp), family = "Inter",), nudge_y = -0.45, | |
size = 12) + | |
scale_size( | |
range = c(0, 90), | |
guide = guide_none()) + | |
scale_x_continuous(expand = expansion(.22)) + | |
scale_y_continuous(expand = expansion(.22)) + | |
theme_void(base_size = 28, base_family = "Inter") + | |
theme( | |
plot.title = element_text(face = "bold"), | |
plot.subtitle = element_text(colour = "#333333"), | |
) + | |
labs( | |
title = "Top 10 economies by GDP", | |
subtitle = "In $US billions in 2023", | |
caption = "Source: International Monetary Fund" | |
) | |
ggsave("test.png", p1, bg = "white", width = 10, height = 13) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment