Skip to content

Commit

Permalink
add some FL palettes
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherkenny committed Dec 30, 2023
1 parent a7706cf commit 77f1bc1
Show file tree
Hide file tree
Showing 9 changed files with 154 additions and 1 deletion.
6 changes: 6 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export(map_coloring)
export(scale_color_538)
export(scale_color_coast)
export(scale_color_dra)
export(scale_color_florida)
export(scale_color_jacksonville)
export(scale_color_larch)
export(scale_color_natgeo)
export(scale_color_party_b)
Expand All @@ -33,6 +35,8 @@ export(scale_color_wiki_rep)
export(scale_color_wiki_rep_pres)
export(scale_colour_coast)
export(scale_colour_dra)
export(scale_colour_florida)
export(scale_colour_jacksonville)
export(scale_colour_larch)
export(scale_colour_natgeo)
export(scale_colour_party_b)
Expand All @@ -43,6 +47,8 @@ export(scale_colour_randmcnally)
export(scale_fill_538)
export(scale_fill_coast)
export(scale_fill_dra)
export(scale_fill_florida)
export(scale_fill_jacksonville)
export(scale_fill_larch)
export(scale_fill_natgeo)
export(scale_fill_party_b)
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# ggredist 0.0.2

* Adds colors and scales to match Wikipedia's typical election mapping colors.
* Adds discrete palettes based on palettes from Jacksonville, FL and Florida statewide.

# ggredist 0.0.1

Expand Down
24 changes: 23 additions & 1 deletion R/colors.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@
#' - **randmcnally** and **natgeo**, colors taken from Rand-McNally and National
#' Geographic political maps
#' - **coast** and **larch**, inspired by natural scenery
#' - **fivethirtyeight**, FiveThirtyEight-inspired color palette
#' - **wiki_dem_pres**: Wikipedia Presidential Democratic palette
#' - **wiki_rep_pres**: Wikipedia Presidential Republican palette
#' - **wiki_dem**: Wikipedia downballot Democratic palette
#' - **wiki_rep**: Wikipedia downballot Republican palette
#' - **wiki_proposal**: Wikipedia proposal support palette
#' - **jacksonville**, Jacksonville, FL inspired color palette
#' - **florida**, Florida 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 @@ -28,6 +31,14 @@
#' plot(ggredist$natgeo)
#' plot(ggredist$coast)
#' plot(ggredist$larch)
#' plot(ggredist$fivethirtyeight)
#' plot(ggredist$wiki_dem_pres)
#' plot(ggredist$wiki_rep_pres)
#' plot(ggredist$wiki_dem)
#' plot(ggredist$wiki_rep)
#' plot(ggredist$wiki_proposal)
#' plot(ggredist$jacksonville)
#' plot(ggredist$florida)
#'
#' @concept colors
#' @export
Expand Down Expand Up @@ -65,6 +76,17 @@ ggredist = list(
class = c("palette", 'character')),
wiki_proposal = structure(c('#2B2457', '#28497C', '#47729E', '#7D9CBB', '#B6C8D9',
'#EBEEED', '#DEDEBD', '#BCBC83', '#8B8B54', '#5D5D2D', '#32320C'),
class = c("palette", 'character'))
class = c("palette", 'character')),
jacksonville = structure(c('#609CA7', '#E4874F', '#6FF87F', '#B770E6', '#5052DD',
'#92B340', '#93EDCA', '#83516A', '#85A6F7', '#448047',
'#3F3E80', '#CA4D6D', '#DCE592', '#918259'),
class = c('palette', 'character')),
florida = structure(c('#F7FDB1', '#D1FDBC', '#FEBBD5', '#C6FEE0', '#C5CAFF',
'#F0C2FD', '#FEC6C9', '#B4FDBF', '#FDF4C4', '#BAB5FD',
'#FFB5B3', '#BDF8FE', '#FFBEF3', '#B6FDCF', '#FDF1D5',
'#C7D8FE', '#FED5E2', '#E4B3FD', '#E0FDD6', '#FDE3B1',
'#FDCFBB', '#DEC8FE', '#D7EFFF', '#DFFDF2', '#FED5FC',
'#B5FFF1', '#B4E5FE', '#EFFDC6'),
class = c('palette', 'character'))
)

60 changes: 60 additions & 0 deletions R/florida.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#' Jacksonville and Florida 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_jacksonville() +
#' theme_map()
#'
#' ggplot(oregon, aes(group = county)) +
#' geom_district() +
#' scale_fill_florida() +
#' theme_map()
#'
#' @concept colors
#' @rdname scale_florida
#' @export
scale_fill_jacksonville <- function(...) {
ggplot2::discrete_scale(aesthetics = 'fill', scale_name = 'jacksonville',
palette = rot_pal(ggredist$jacksonville), ...)
}

#' @rdname scale_florida
#' @concept colors
#' @export
scale_color_jacksonville <- function(...) {
ggplot2::discrete_scale(aesthetics = 'color', scale_name = 'jacksonville',
palette = rot_pal(ggredist$jacksonville), ...)
}
#' @rdname scale_florida
#' @concept colors
#' @export
scale_colour_jacksonville = scale_color_jacksonville


#' @rdname scale_florida
#' @concept colors
#' @export
scale_fill_florida <- function(...) {
ggplot2::discrete_scale(aesthetics = 'fill', scale_name = 'florida',
palette = rot_pal(ggredist$florida), ...)
}

#' @rdname scale_florida
#' @concept colors
#' @export
scale_color_florida <- function(...) {
ggplot2::discrete_scale(aesthetics = 'color', scale_name = 'florida',
palette = rot_pal(ggredist$florida), ...)
}
#' @rdname scale_florida
#' @concept colors
#' @export
scale_colour_florida = scale_color_florida
2 changes: 2 additions & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ knitr::opts_chunk$set(

<!-- badges: start -->
[![R-CMD-check](https://github.com/alarm-redist/ggredist/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/alarm-redist/ggredist/actions/workflows/R-CMD-check.yaml)
[![](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)
[![r-universe status badge](https://alarm-redist.r-universe.dev/badges/ggredist)](https://alarm-redist.r-universe.dev/ui#package:ggredist)
<!-- badges: end -->

`ggredist` provides `ggplot2` extensions for political mapmaking, including
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
<!-- badges: start -->

[![R-CMD-check](https://github.com/alarm-redist/ggredist/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/alarm-redist/ggredist/actions/workflows/R-CMD-check.yaml)
[![](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)
[![r-universe status
badge](https://alarm-redist.r-universe.dev/badges/ggredist)](https://alarm-redist.r-universe.dev/ui#package:ggredist)
<!-- badges: end -->

`ggredist` provides `ggplot2` extensions for political mapmaking,
Expand Down
Binary file modified man/figures/README-example-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions man/ggredist.Rd

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

48 changes: 48 additions & 0 deletions man/scale_florida.Rd

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

0 comments on commit 77f1bc1

Please sign in to comment.