Skip to content

Instantly share code, notes, and snippets.

@idmn
Last active June 7, 2022 13:54
Show Gist options
  • Save idmn/bcbc6dec8226a9b51d98ecc32d281776 to your computer and use it in GitHub Desktop.
Save idmn/bcbc6dec8226a9b51d98ecc32d281776 to your computer and use it in GitHub Desktop.
library(ggplot2)
library(dplyr)
library(ggbeeswarm)
cities <- c(
"Portland", "New York City", "Chicago", "Detroit",
"New Haven", "Boston", "Philadelphia", "St. Louis"
)
slice_data <- tibble(
city = rep(cities, each = 2),
part = rep(c("main", "border"), length(cities)),
r = rep(c(1, 0.1), length(cities))
)
pep_data <-
tibble(
city = sample(cities, 50, replace = TRUE),
r = runif(50, 0.1, 0.9) %>% sqrt() %>% round(1)
)
ggplot(mapping = aes(x = city, y = r)) +
geom_bar(
data = slice_data,
mapping = aes(group = part, fill = city, alpha = part),
width = 1, stat = "identity"
) +
geom_quasirandom(data = pep_data, size = 4, color = "#cc5533", groupOnX = TRUE) +
coord_polar("x", start = 0) +
scale_alpha_manual(values = c(main = 0.6, border = 1)) +
guides(fill = "none", alpha = "none") +
labs(x = NULL, y = NULL) +
theme_minimal() +
theme(
axis.text.y = element_blank(),
panel.grid = element_blank()
) +
NULL
@idmn
Copy link
Author

idmn commented Jun 7, 2022

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment