p_gdp_s <- ggplot(socio_df, aes(x = gdp_per_capita, y = tb_incidence)) +
geom_point(aes(color = region), size = 2.2, alpha = 0.75, shape = 16) +
geom_smooth(
method = "lm", color = "#2c2c2c", linewidth = 0.85,
fill = "grey75", alpha = 0.2, se = TRUE
) +
geom_text_repel(
data = filter(socio_df, tb_incidence >= tb_thresh_socio),
aes(label = country, color = region),
size = 2.5, fontface = "italic", max.overlaps = 15,
box.padding = 0.35, segment.color = "grey60",
segment.size = 0.3, show.legend = FALSE
) +
annotate("label",
x = Inf, y = Inf, hjust = 1.05, vjust = 1.4,
label = paste0("R\u00b2 = ", round(r2_g_s, 3)),
size = 3.2, fill = "white", label.size = 0.3,
label.r = unit(0.12, "lines"), color = "#2c2c2c"
) +
scale_x_log10(labels = label_dollar(scale_cut = cut_short_scale())) +
scale_y_continuous(labels = comma_format(accuracy = 1)) +
scale_color_brewer(palette = "Set2", name = NULL) +
labs(
title = "GDP per Capita vs TB Incidence",
subtitle = "Log scale \u00b7 OLS fit with 95% CI \u00b7 Top 10% burden labelled",
x = "GDP per capita (log scale, USD)",
y = "TB incidence per 100,000"
) +
theme_minimal(base_size = 11) +
theme(
plot.title = element_text(face = "bold", size = 12, hjust = 0),
plot.subtitle = element_text(color = "grey45", size = 8, hjust = 0, margin = margin(b = 6)),
panel.grid.minor = element_blank(),
panel.grid.major = element_line(color = "grey93"),
legend.position = "none",
axis.text = element_text(size = 8.5, color = "grey40"),
axis.title = element_text(size = 9, color = "grey30"),
plot.margin = margin(10, 12, 6, 10)
)
p_hlth_s <- ggplot(socio_df, aes(x = health_expenditure, y = tb_incidence)) +
geom_point(aes(color = region), size = 2.2, alpha = 0.75, shape = 16) +
geom_smooth(
method = "lm", color = "#2c2c2c", linewidth = 0.85,
fill = "grey75", alpha = 0.2, se = TRUE
) +
geom_text_repel(
data = filter(socio_df, tb_incidence >= tb_thresh_socio),
aes(label = country, color = region),
size = 2.5, fontface = "italic", max.overlaps = 15,
box.padding = 0.35, segment.color = "grey60",
segment.size = 0.3, show.legend = FALSE
) +
annotate("label",
x = Inf, y = Inf, hjust = 1.05, vjust = 1.4,
label = paste0("R\u00b2 = ", round(r2_h_s, 3)),
size = 3.2, fill = "white", label.size = 0.3,
label.r = unit(0.12, "lines"), color = "#2c2c2c"
) +
scale_y_continuous(labels = comma_format(accuracy = 1)) +
scale_color_brewer(palette = "Set2", name = "Region") +
labs(
title = "Health Expenditure vs TB Incidence",
subtitle = "% of GDP \u00b7 OLS fit with 95% CI \u00b7 Top 10% burden labelled",
x = "Health expenditure (% of GDP)",
y = "TB incidence per 100,000"
) +
theme_minimal(base_size = 11) +
theme(
plot.title = element_text(face = "bold", size = 12, hjust = 0),
plot.subtitle = element_text(color = "grey45", size = 8, hjust = 0, margin = margin(b = 6)),
panel.grid.minor = element_blank(),
panel.grid.major = element_line(color = "grey93"),
legend.position = "right",
legend.text = element_text(size = 8),
legend.key.size = unit(0.45, "cm"),
axis.text = element_text(size = 8.5, color = "grey40"),
axis.title = element_text(size = 9, color = "grey30"),
plot.margin = margin(10, 12, 6, 10)
)
(p_gdp_s | p_hlth_s) +
plot_annotation(
title = paste0("Socioeconomic Determinants of TB Incidence (", socio_year, ")"),
caption = "Source: World Bank WDI",
theme = theme(
plot.title = element_text(face = "bold", size = 14, hjust = 0),
plot.caption = element_text(color = "grey55", size = 8, hjust = 1)
)
) +
plot_layout(guides = "collect") &
theme(legend.position = "bottom")