Skip to content

Instantly share code, notes, and snippets.

@hafen
Created May 28, 2020 18:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save hafen/e3641ae5a24b49f4ae4b393fad9f201b to your computer and use it in GitHub Desktop.
Save hafen/e3641ae5a24b49f4ae4b393fad9f201b to your computer and use it in GitHub Desktop.
library(geofacet)
library(ggplot2)
# original plot
ggplot(election, aes(candidate, votes / 1000000, fill = candidate)) +
geom_col() +
scale_fill_manual(values = c("#4e79a7", "#e15759", "#59a14f")) +
facet_geo(~ state, grid = "us_state_grid2") +
coord_flip() +
ylab("Votes (millions)")
# shrink facet labels
ggplot(election, aes(candidate, votes / 1000000, fill = candidate)) +
geom_col() +
scale_fill_manual(values = c("#4e79a7", "#e15759", "#59a14f")) +
facet_geo(~ state, grid = "us_state_grid2") +
coord_flip() +
ylab("Votes (millions)") +
theme(strip.text.x = element_text(size = 6, margin = margin(0.5, 0, 0.5, 0, "mm")))
# remove facet labels
ggplot(election, aes(candidate, votes / 1000000, fill = candidate)) +
geom_col() +
scale_fill_manual(values = c("#4e79a7", "#e15759", "#59a14f")) +
facet_geo(~ state, grid = "us_state_grid2") +
coord_flip() +
ylab("Votes (millions)") +
theme(strip.background = element_blank(), strip.text.x = element_blank())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment