Last active
June 7, 2022 13:54
-
-
Save idmn/bcbc6dec8226a9b51d98ecc32d281776 to your computer and use it in GitHub Desktop.
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
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 |
Author
idmn
commented
Jun 7, 2022
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment