Skip to content

Instantly share code, notes, and snippets.

@arvi1000
Created October 11, 2019 02:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arvi1000/9e13c187662badd4c78445602efcaee4 to your computer and use it in GitHub Desktop.
Save arvi1000/9e13c187662badd4c78445602efcaee4 to your computer and use it in GitHub Desktop.
Changing label colors with rGridMap
devtools::install_github('arvi1000/rGridMap')
library(rGridMap)
library(ggplot2)
# a data.frame of states with random categorical value
set.seed(123)
my_dat <- data.frame(state.abb = c(state.abb, 'DC'), # don't forget DC!
value=sample(LETTERS[1:5], 51, replace=T))
plotGridMap(my_dat, fill_var = 'value',
# this turns labels white
label_color = 'white') +
scale_fill_brewer(type='qual', palette = 2) +
labs(title = 'States by Category', fill = 'Category',
subtitle = 'black background, white state labels') +
# this is to make background black
theme(rect = element_rect(fill='black'),
text = element_text(color='white'),
legend.key= element_blank())
@arvi1000
Copy link
Author

image

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