Skip to content

Commit

Permalink
pretty washington map colors
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherkenny committed Jan 5, 2024
1 parent 77f1bc1 commit adb3660
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 1 deletion.
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export(scale_color_party_c)
export(scale_color_party_d)
export(scale_color_penn82)
export(scale_color_randmcnally)
export(scale_color_washington)
export(scale_color_wiki_dem)
export(scale_color_wiki_dem_pres)
export(scale_color_wiki_rep)
Expand All @@ -44,6 +45,7 @@ export(scale_colour_party_c)
export(scale_colour_party_d)
export(scale_colour_penn82)
export(scale_colour_randmcnally)
export(scale_colour_washington)
export(scale_fill_538)
export(scale_fill_coast)
export(scale_fill_dra)
Expand All @@ -56,6 +58,7 @@ export(scale_fill_party_c)
export(scale_fill_party_d)
export(scale_fill_penn82)
export(scale_fill_randmcnally)
export(scale_fill_washington)
export(scale_fill_wiki_dem)
export(scale_fill_wiki_dem_pres)
export(scale_fill_wiki_rep)
Expand Down
8 changes: 7 additions & 1 deletion R/colors.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#' - **wiki_proposal**: Wikipedia proposal support palette
#' - **jacksonville**, Jacksonville, FL inspired color palette
#' - **florida**, Florida inspired color palette
#' - **washington**, Washington Redistricting Commission inspired color palette
#'
#' For details on Wikipedia-based colors, see
#' <https://en.wikipedia.org/wiki/Wikipedia:WikiProject_Elections_and_Referendums/USA_legend_colors>.
Expand All @@ -39,6 +40,7 @@
#' plot(ggredist$wiki_proposal)
#' plot(ggredist$jacksonville)
#' plot(ggredist$florida)
#' plot(ggredist$washington)
#'
#' @concept colors
#' @export
Expand Down Expand Up @@ -87,6 +89,10 @@ ggredist = list(
'#C7D8FE', '#FED5E2', '#E4B3FD', '#E0FDD6', '#FDE3B1',
'#FDCFBB', '#DEC8FE', '#D7EFFF', '#DFFDF2', '#FED5FC',
'#B5FFF1', '#B4E5FE', '#EFFDC6'),
class = c('palette', 'character'))
class = c('palette', 'character')),
washington = structure(c('#993A5B', '#1E5769', '#D98B79', '#D9CC46', '#2AA99C',
'#F1C1B8', '#533742', '#ABD2C5', '#976C81', '#239C78',
'#A36D02', '#2A3944'),
class = c('palette', 'character'))
)

34 changes: 34 additions & 0 deletions R/washington.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#' Washington Redistricting Commission Color Scales for `ggplot2`
#'
#' @param ... Arguments passed on to [ggplot2::discrete_scale()]
#'
#' @return ggplot scale function
#'
#' @examples
#' library(ggplot2)
#' data(oregon)
#'
#' ggplot(oregon, aes(group = county)) +
#' geom_district() +
#' scale_fill_washington() +
#' theme_map()
#'
#' @concept colors
#' @rdname scale_washington
#' @export
scale_fill_washington <- function(...) {
ggplot2::discrete_scale(aesthetics = 'fill', scale_name = 'washington',
palette = rot_pal(ggredist$washington), ...)
}

#' @rdname scale_washington
#' @concept colors
#' @export
scale_color_washington <- function(...) {
ggplot2::discrete_scale(aesthetics = 'color', scale_name = 'washington',
palette = rot_pal(ggredist$washington), ...)
}
#' @rdname scale_washington
#' @concept colors
#' @export
scale_colour_washington = scale_color_washington
2 changes: 2 additions & 0 deletions man/ggredist.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions man/scale_washington.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit adb3660

Please sign in to comment.