gapminder_cleaned <- gapminder %>%
filter(year == "2007") %>%
mutate(
pop2 = pop + 1,
continent = case_when(
continent == "Oceania" ~ "Asia",
TRUE ~ as.character(continent)
) %>% as.factor %>%
fct_relevel("Asia", "Americas", "Europe", "Africa")
)
(gapminder_plot <- ggplot(data = gapminder_cleaned, aes(x = gdpPercap, y = lifeExp)) +
annotate("text", x = 4000, y = 45, hjust = 0.5,
size = 55, color = "#999999",
label = "2007", alpha = .3,
family = "Helvetica Neue") +
geom_point(aes(size = pop, color = continent)) +
geom_point(aes(size = pop2), color = "black", shape = 21) +
scale_x_log10(breaks = c(500, 1000, 2000, 4000,
8000, 16000, 32000, 64000)) +
scale_y_continuous(breaks = seq(0, 90, by = 10)) +
scale_color_manual(values = c("#F15772", "#7EEB03",
"#FBE700", "#54D5E9")) +
scale_size_continuous(range = c(1, 30)) +
guides(size = FALSE, color = FALSE) +
labs(
x = "Income",
y = "Life expectancy"
) +
theme_minimal() +
theme(
plot.margin = unit(rep(1, 4), "cm"),
panel.grid.minor = element_blank(),
panel.grid.major = element_line(size = 0.2,
color = "#e5e5e5"),
axis.title.y = element_text(margin = margin(r = 15),
size = 11,
family = "Helvetica Neue Light"),
axis.title.x = element_text(margin = margin(t = 15),
size = 11,
family = "Helvetica Neue Light"),
axis.text = element_text(family = "Helvetica Neue Light"),
axis.line = element_line(color = "#999999",
size = 0.2)
) +
theme(
axis.title.y = element_text(margin = margin(r = 15),
size = 11,
family = "Helvetica Neue Light"),
axis.title.x = element_text(margin = margin(t = 15),
size = 11,
family = "Helvetica Neue Light"),
axis.text = element_text(family = "Helvetica Neue Light"),
axis.line = element_line(color = "#999999",
size = 0.2)
) +
coord_cartesian(ylim = c(4, 100)))
