Skip to content

Instantly share code, notes, and snippets.

@ctesta01
Last active July 19, 2022 15:06
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 ctesta01/6d84d24af94b1c11d7b031e4e2ce254e to your computer and use it in GitHub Desktop.
Save ctesta01/6d84d24af94b1c11d7b031e4e2ce254e to your computer and use it in GitHub Desktop.
Example showing Blue/Orange Diverging Color Palette
library(sf)
library(ggplot2)
nc <- st_read(system.file("shapes/sids.shp", package="spData")[1], quiet=TRUE)
nc %>%
ggplot(aes(fill = AREA)) +
geom_sf(size = 0.05, color = 'white') +
scale_fill_gradientn(
colors = c("#DA8907", "#ECCD00", "white", "#62AEDC", "#203856"))
nc %>%
ggplot(aes(fill = AREA)) +
geom_sf(size = 0.05, color = 'white') +
scale_fill_stepsn(
colors = c("#DA8907", "#ECCD00", "white", "#62AEDC", "#203856"))
# note that the breaks and range of values can be specified manually by using the values argument
@ctesta01
Copy link
Author

example showing continuous palette

example showing discrete palette

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