Skip to content

Instantly share code, notes, and snippets.

@z3tt
Created July 4, 2026 14:06
Show Gist options
  • Select an option

  • Save z3tt/4bd419aa60ef2d865282cc3829b96553 to your computer and use it in GitHub Desktop.

Select an option

Save z3tt/4bd419aa60ef2d865282cc3829b96553 to your computer and use it in GitHub Desktop.
US Star Map
library(geofacet)
library(ggstar)
letter_positions <- factor(LETTERS)
us_state_grid2$starts_with <- substr(us_state_grid2$name, 1, 1)
us_state_grid2$starts_with_grad <- as.numeric(factor(us_state_grid2$starts_with, levels = letter_positions))
ggplot(us_state_grid2, aes(x = 1, y = 1)) +
geom_star(aes(fill = starts_with_grad), starstroke = 0, size = 20) +
geom_text(
aes(label = starts_with, color = starts_with_grad < 6 | starts_with_grad > 18),
family = "Asap", fontface = "bold"
) +
facet_geo(~ name, grid = "us_state_grid2") +
#scico::scale_fill_scico(palette = )
scale_fill_gradient2(
low = "#B31942", mid = "#FFFFFF", high = "#0A3161", midpoint = 13,
breaks = as.numeric(letter_positions), labels = paste(letter_positions, " "),
name = "First Letter: ",
guide = guide_legend(override.aes = list(size = 5.5), nrow = 1)
) +
scale_color_manual(values = c("black", "white"), guide = "none") +
theme_void(base_size = 12, base_family = "Asap Condensed",
ink = "grey65", paper = "black") +
theme(
legend.position = "bottom",
legend.box.margin = margin_part(t = 15),
legend.title = element_text(size = rel(.9), face = "bold", family = "Asap"),
legend.text = element_text(size = rel(.9), face = "bold"),
plot.margin = margin_auto(25),
strip.text = element_text(size = rel(.75), face = "bold", margin = margin_part(b = 5)),
plot.background = element_rect(fill = "black"),
panel.spacing.x = unit(1.3, "lines"),
panel.spacing.y = unit(.8, "lines")
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment