Skip to content

Commit

Permalink
add alaska colors
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherkenny committed Jun 13, 2024
1 parent ef0168f commit 0d934c7
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Package: ggredist
Title: Scales, Geometries, and Extensions of 'ggplot2' for Election Mapping
Version: 0.0.2
Authors@R: c(
person("Cory", "McCartan", email = "[email protected].edu", role = "aut"),
person("Cory", "McCartan", email = "mccartan@psu.edu", role = "aut"),
person("Christopher T.", "Kenny", email = "[email protected]",
role = c("aut", "cre"), comment = c(ORCID = "0000-0002-9386-6860")))
Description: Provides 'ggplot2' extensions for political map making. Implements
Expand Down
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export(label_party_margin)
export(label_party_pct)
export(map_coloring)
export(scale_color_538)
export(scale_color_alaska)
export(scale_color_coast)
export(scale_color_dra)
export(scale_color_florida)
Expand All @@ -33,6 +34,7 @@ export(scale_color_wiki_dem)
export(scale_color_wiki_dem_pres)
export(scale_color_wiki_rep)
export(scale_color_wiki_rep_pres)
export(scale_colour_alaska)
export(scale_colour_coast)
export(scale_colour_dra)
export(scale_colour_florida)
Expand All @@ -46,6 +48,7 @@ export(scale_colour_penn82)
export(scale_colour_randmcnally)
export(scale_colour_washington)
export(scale_fill_538)
export(scale_fill_alaska)
export(scale_fill_coast)
export(scale_fill_dra)
export(scale_fill_florida)
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# ggredist 0.0.03

* Adds new discrete color palettes from Washingtonian and Alaskan redistricting proceses.
* Replaces internal palette class with the palette class from the [palette R package](https://christophertkenny.com/palette/).

# ggredist 0.0.2

* Adds colors and scales to match Wikipedia's typical election mapping colors.
Expand Down
34 changes: 34 additions & 0 deletions R/alaska.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#' Alaska 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_alaska() +
#' theme_map()
#'
#' @concept colors
#' @rdname scale_alaska
#' @export
scale_fill_alaska <- function(...) {
ggplot2::discrete_scale(aesthetics = 'fill', scale_name = 'alaska',
palette = palette::palette_function(ggredist$alaska), ...)
}

#' @rdname scale_alaska
#' @concept colors
#' @export
scale_color_alaska <- function(...) {
ggplot2::discrete_scale(aesthetics = 'color', scale_name = 'alaska',
palette = palette::palette_function(ggredist$alaska), ...)
}
#' @rdname scale_alaska
#' @concept colors
#' @export
scale_colour_alaska = scale_color_alaska
9 changes: 8 additions & 1 deletion R/colors.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#' - **jacksonville**, Jacksonville, FL inspired color palette
#' - **florida**, Florida inspired color palette
#' - **washington**, Washington Redistricting Commission inspired color palette
#' - **alaska**, Alaska 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 @@ -41,6 +42,7 @@
#' plot(ggredist$jacksonville)
#' plot(ggredist$florida)
#' plot(ggredist$washington)
#' plot(ggredist$alaska)
#'
#' @concept colors
#' @export
Expand Down Expand Up @@ -84,6 +86,11 @@ ggredist = list(
'#B5FFF1', '#B4E5FE', '#EFFDC6')),
washington = palette::palette(c('#993A5B', '#1E5769', '#D98B79', '#D9CC46', '#2AA99C',
'#F1C1B8', '#533742', '#ABD2C5', '#976C81', '#239C78',
'#A36D02', '#2A3944'))
'#A36D02', '#2A3944')),
alaska = palette::palette(c("#8FAD6A", "#A66A8F", "#82BBB4", "#7383BA",
"#C6A46B", "#C4DC94", "#6691AD", "#A87C78",
"#C8867A", "#4DD7FF", "#A17CB8", "#BF6884",
"#A89264", "#BB6FC8", "#ADBA83"
))
)

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_alaska.Rd

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

0 comments on commit 0d934c7

Please sign in to comment.