What is this type of data visualization plot called and how do I recreate it in R?
My Google search only resulted in regular bubble plots like this: https://r-graph-gallery.com/320-the-basis-of-bubble-plot.html
What is this type of data visualization plot called and how do I recreate it in R?
My Google search only resulted in regular bubble plots like this: https://r-graph-gallery.com/320-the-basis-of-bubble-plot.html
Here's an example. Lots more formatting tweaks could be done, but I'd think of this fundamentally as a geom_point
and a geom_text
layer, the rest is tidying up.
library(ggplot2)
fake_data <- data.frame(x = rep(LETTERS[1:3], each = 4),
y = letters[1:4],
val = (1:12) / 12)
ggplot(fake_data, aes(x=1, y = 1, label = scales::percent(val))) +
geom_point(aes(size = val, color = x), alpha = 0.3) +
geom_text() +
scale_size_area(max_size = 20) +
guides(size = "none", color = "none") +
facet_grid(y ~ x, switch = "y") +
theme_void() +
theme(strip.text = element_text())
Something like this?
df <- data.frame(Question = rep(c("Getting\nhigh-paying jobs",
"Being leaders in\ntheir community",
"Expressing their\npolitical views",
"Getting a good\neducation"), 3),
Answer = rep(c("Men have more\nopportunities",
"Women have more\nopportunities",
"Both about\nthe same"), each = 4),
Value = c(54, 44, 31, 11, 3, 4, 3, 6, 38, 49, 63, 81))
library(ggplot2)
ggplot(df, aes(y = factor(Question, rev(unique(Question))),
x = factor(Answer, unique(Answer)),
fill = factor(Answer, unique(Answer)))) +
geom_point(shape = 21, aes(size = Value, color = after_scale(fill))) +
geom_text(aes(label = Value, color = Answer)) +
annotate("segment", x = rep(-Inf, 3), xend = rep(Inf, 3),
y = 1:3 + 0.5, yend = 1:3 + 0.5, linetype = 2, alpha = 0.5) +
scale_y_discrete() +
scale_x_discrete(position = "top") +
scale_size_continuous(range = c(5, 30)) +
scale_fill_manual(values = c("#959e4a", "#0f6599", "#dddac8")) +
scale_color_manual(values = c("black", "white", "white")) +
ggtitle(paste("Many think men have more opportunities than women",
"when it comes to getting high-paid jobs", sep = "\n")) +
theme_void() +
theme(legend.position = "none",
axis.text.x = element_text(face = 2),
axis.text.y = element_text(hjust = 1, face = 2),
plot.margin = margin(30, 30, 30, 30),
plot.title = element_text(size = 16, face = 2, family = "serif",
margin = margin(20, 0, 50, 0)))