Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] [DO NOT MERGE] Add Tol palettes #371

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ Authors@R:
person(given = "Matthew",
family = "Smith",
role = "rev",
email = "[email protected]",
comment = c(Twitter = "@SmithMatt90")),
email = "[email protected]"),
person(given = "Jakob",
family = "Bossek",
role = "rev",
Expand Down Expand Up @@ -121,4 +120,3 @@ Config/testthat/edition: 3
Config/testthat/parallel: true
Config/Needs/website: easystats/easystatstemplate
Config/rcmdcheck/ignore-inconsequential-notes: true
Remotes: easystats/performance, easystats/parameters
5 changes: 5 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export(palette_okabeito)
export(palette_pizza)
export(palette_see)
export(palette_social)
export(palette_tol_discrete)
export(pizza_colors)
export(plots)
export(scale_color_bluebrown)
Expand Down Expand Up @@ -138,6 +139,7 @@ export(scale_color_see_d)
export(scale_color_social)
export(scale_color_social_c)
export(scale_color_social_d)
export(scale_color_tol_discrete)
export(scale_colour_bluebrown)
export(scale_colour_bluebrown_c)
export(scale_colour_bluebrown_d)
Expand All @@ -164,6 +166,7 @@ export(scale_colour_see_d)
export(scale_colour_social)
export(scale_colour_social_c)
export(scale_colour_social_d)
export(scale_colour_tol_discrete)
export(scale_fill_bluebrown)
export(scale_fill_bluebrown_c)
export(scale_fill_bluebrown_d)
Expand All @@ -190,6 +193,7 @@ export(scale_fill_see_d)
export(scale_fill_social)
export(scale_fill_social_c)
export(scale_fill_social_d)
export(scale_fill_tol_discrete)
export(see_colors)
export(social_colors)
export(theme_abyss)
Expand All @@ -198,4 +202,5 @@ export(theme_lucid)
export(theme_modern)
export(theme_radar)
export(theme_radar_dark)
export(tol_colors)
import(ggplot2)
20 changes: 3 additions & 17 deletions R/scale_color_flat.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
}



# Aliases -----------------------------------------------------------------


Expand Down Expand Up @@ -94,13 +93,9 @@
scale_colour_flat_d <- scale_color_flat_d





# Fill --------------------------------------------------------------------



#' @rdname scale_color_flat
#' @export
scale_fill_flat <- function(palette = "contrast",
Expand Down Expand Up @@ -134,6 +129,7 @@
)
}


#' @rdname scale_color_flat
#' @export
scale_fill_flat_c <- function(palette = "contrast",
Expand All @@ -151,31 +147,26 @@
}





# Palette --------------------------------------------------------------------




# The palette based on flat design colors: https://www.materialui.co/flatuicolors
flat_colors_list <- c(
`red` = "#e74c3c",

Check warning on line 155 in R/scale_color_flat.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/scale_color_flat.R,line=155,col=3,[keyword_quote_linter] Only quote named arguments to functions if necessary, i.e., if the name is not a valid R symbol (see ?make.names).
`dark red` = "#c0392b",
`purple` = "#9b59b6",

Check warning on line 157 in R/scale_color_flat.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/scale_color_flat.R,line=157,col=3,[keyword_quote_linter] Only quote named arguments to functions if necessary, i.e., if the name is not a valid R symbol (see ?make.names).
`deep purple` = "#8e44ad",
`blue` = "#2980b9",

Check warning on line 159 in R/scale_color_flat.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/scale_color_flat.R,line=159,col=3,[keyword_quote_linter] Only quote named arguments to functions if necessary, i.e., if the name is not a valid R symbol (see ?make.names).
`light blue` = "#3498db",
`cyan` = "#1abc9c",

Check warning on line 161 in R/scale_color_flat.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/scale_color_flat.R,line=161,col=3,[keyword_quote_linter] Only quote named arguments to functions if necessary, i.e., if the name is not a valid R symbol (see ?make.names).
`teal` = "#16a085",

Check warning on line 162 in R/scale_color_flat.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/scale_color_flat.R,line=162,col=3,[keyword_quote_linter] Only quote named arguments to functions if necessary, i.e., if the name is not a valid R symbol (see ?make.names).
`green` = "#27ae60",

Check warning on line 163 in R/scale_color_flat.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/scale_color_flat.R,line=163,col=3,[keyword_quote_linter] Only quote named arguments to functions if necessary, i.e., if the name is not a valid R symbol (see ?make.names).
`light green` = "#2ecc71",
`yellow` = "#f1c40f",

Check warning on line 165 in R/scale_color_flat.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/scale_color_flat.R,line=165,col=3,[keyword_quote_linter] Only quote named arguments to functions if necessary, i.e., if the name is not a valid R symbol (see ?make.names).
`amber` = "#f39c12",

Check warning on line 166 in R/scale_color_flat.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/scale_color_flat.R,line=166,col=3,[keyword_quote_linter] Only quote named arguments to functions if necessary, i.e., if the name is not a valid R symbol (see ?make.names).
`orange` = "#e67e22",

Check warning on line 167 in R/scale_color_flat.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/scale_color_flat.R,line=167,col=3,[keyword_quote_linter] Only quote named arguments to functions if necessary, i.e., if the name is not a valid R symbol (see ?make.names).
`deep orange` = "#d35400",
`grey` = "#95a5a6",

Check warning on line 169 in R/scale_color_flat.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/scale_color_flat.R,line=169,col=3,[keyword_quote_linter] Only quote named arguments to functions if necessary, i.e., if the name is not a valid R symbol (see ?make.names).
`blue grey` = "#7f8c8d"
)

Expand Down Expand Up @@ -205,8 +196,6 @@
}




flat_palettes <- list(
`full` = flat_colors(),
`ice` = flat_colors("purple", "deep purple", "blue", "light blue"),
Expand Down Expand Up @@ -239,9 +228,6 @@






#' Flat UI color palette
#'
#' The palette based on [Flat UI](https://materialui.co/flatuicolors).
Expand All @@ -251,10 +237,10 @@
#' `"contrast"`, `"light"` (for dark themes), `"black_first"`, `full_original`,
#' or `black_first_original`.
#' @param reverse Boolean indicating whether the palette should be reversed.
#' @param ... Additional arguments to pass to [`colorRampPalette()`][colorRampPalette].
#' @param ... Additional arguments to pass to [`grDevices::colorRampPalette()`].
#'
#' @details This function is usually not called directly, but from within
#' [`scale_color_flat()`][scale_color_flat].
#' [`scale_color_flat()`].
#'
#' @export
palette_flat <- function(palette = "contrast", reverse = FALSE, ...) {
Expand Down
35 changes: 17 additions & 18 deletions R/scale_color_metro.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#' Metro color palette
#'
#' The palette based on Metro [Metro
#' colors](https://materialui.co/metrocolors).
#' Use `scale_color_metro_d` for *discrete* categories and
#' `scale_color_metro_c` for a *continuous* scale.
#' The palette based on Metro [Metro colors](https://materialui.co/metrocolors).
#' Use `scale_color_metro_d` for *discrete* categories and `scale_color_metro_c`
#' for a *continuous* scale.
#'
#' @inheritParams palette_metro
#' @inheritParams scale_color_flat
Expand Down Expand Up @@ -158,18 +157,18 @@ scale_fill_metro_c <- function(palette = "complement",

# The palette based on metro design colors: https://www.materialui.co/metrocolors
metro_colors_list <- c(
`red` = "#e51400",
red = "#e51400",
`dark red` = "#a20025",
`purple` = "#aa00ff",
purple = "#aa00ff",
`deep purple` = "#76608a",
`blue` = "#0050ef",
blue = "#0050ef",
`light blue` = "#1ba1e2",
`teal` = "#00aba9",
`green` = "#008a00",
teal = "#00aba9",
green = "#008a00",
`light green` = "#60a917",
`yellow` = "#e3c800",
`amber` = "#f0a30a",
`orange` = "#fa6800",
yellow = "#e3c800",
amber = "#f0a30a",
orange = "#fa6800",
`deep orange` = "#a0522d",
`blue grey` = "#647687"
)
Expand Down Expand Up @@ -203,9 +202,9 @@ metro_colors <- function(...) {


metro_palettes <- list(
`full` = metro_colors(),
`ice` = metro_colors("purple", "deep purple", "blue", "light blue"),
`rainbow` = metro_colors(
full = metro_colors(),
ice = metro_colors("purple", "deep purple", "blue", "light blue"),
rainbow = metro_colors(
"purple",
"deep purple",
"blue",
Expand All @@ -217,9 +216,9 @@ metro_palettes <- list(
"deep orange",
"red"
),
`contrast` = metro_colors("blue", "green", "amber", "purple", "red"),
`light` = material_colors("light blue", "red", "yellow", "light green", "orange"),
`complement` = metro_colors(
contrast = metro_colors("blue", "green", "amber", "purple", "red"),
light = material_colors("light blue", "red", "yellow", "light green", "orange"),
complement = metro_colors(
"blue grey",
"blue",
"light blue",
Expand Down
46 changes: 24 additions & 22 deletions R/scale_color_okabeito.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#'
#' The Okabe-Ito palette is only available as a discrete palette.
#' For color-accessible continuous variables, consider
#' [Paul Tol's palettes][scale_color_tol_discrete()] or
#' [the viridis palettes][ggplot2::scale_colour_viridis_d()].
#'
#' @inheritParams palette_okabeito
Expand Down Expand Up @@ -100,22 +101,23 @@ scale_fill_oi <- scale_fill_okabeito
# Palette --------------------------------------------------------------------

# The palette from: https://jfly.uni-koeln.de/color/#pallet
# or grDevices::palette.colors()
okabeito_colors_list <- c(
`orange` = "#E69F00",
orange = "#E69F00",
`light blue` = "#56B4E9",
`green` = "#009E73",
`yellow` = "#F0E442",
`blue` = "#0072B2",
`red` = "#D55E00",
`purple` = "#CC79A7",
`grey` = "#999999",
`black` = "#000000",
green = "#009E73",
yellow = "#F0E442",
blue = "#0072B2",
red = "#D55E00",
purple = "#CC79A7",
grey = "#999999",
black = "#000000",
`sky blue` = "#56B4E9",
`bluish green` = "#009E73",
`vermillion` = "#D55E00",
vermillion = "#D55E00",
`reddish purple` = "#CC79A7",
`dark yellow` = "#F5C710",
`amber` = "#F5C710"
amber = "#F5C710"
)


Expand All @@ -127,11 +129,11 @@ okabeito_colors_list <- c(
#' @inheritParams flat_colors
#' @param original_names Logical. Should the colors be named using the original
#' names used by Okabe and Ito (2008), such as "vermillion" (`TRUE`), or
#' simplified names, such as "red" (`FALSE`, default)?
#' Only used if no colors are specified (to see all available colors).
#' @param black_first Logical. Should black be first (`TRUE`) or last (`FALSE`, default)
#' in the color palette? Only used if no colors are specified (to see all
#' available colors).
#' simplified names, such as "red" (`FALSE`, default)? Only used if no colors
#' are specified (to see all available colors).
#' @param black_first Logical. Should black be first (`TRUE`) or last (`FALSE`,
#' default) in the color palette? Only used if no colors are specified (to see
#' all available colors).
#' @param amber If amber color should replace yellow in the palette.
#'
#' @return A character vector with color-codes.
Expand Down Expand Up @@ -170,16 +172,16 @@ okabeito_colors <- function(..., original_names = FALSE, black_first = FALSE, am
oi_colors <- okabeito_colors

okabeito_palettes <- list(
`full` = okabeito_colors(black_first = FALSE, amber = TRUE),
`black_first` = okabeito_colors(black_first = TRUE, amber = TRUE),
`full_original` = okabeito_colors(black_first = FALSE, amber = FALSE),
`black_original` = okabeito_colors(black_first = TRUE, amber = FALSE)
full = okabeito_colors(black_first = FALSE, amber = TRUE),
black_first = okabeito_colors(black_first = TRUE, amber = TRUE),
full_original = okabeito_colors(black_first = FALSE, amber = FALSE),
black_original = okabeito_colors(black_first = TRUE, amber = FALSE)
)


#' Okabe-Ito color palette
#'
#' The palette based proposed by Okabe and Ito (2008).
#' The palette based on Okabe and Ito (2008).
#'
#' @inheritParams palette_flat
#' @param order A vector of numbers from 1 to 9 indicating the order of colors to use
Expand All @@ -191,7 +193,7 @@ okabeito_palettes <- list(
#' https://jfly.uni-koeln.de/color/#pallet (Original work published 2002)
#'
#' @details This function is usually not called directly, but from within
#' [`scale_color_material()`][scale_color_material].
#' [`scale_color_okabeito()`][scale_color_okabeito].
#'
#' @export
palette_okabeito <- function(palette = "full_amber", reverse = FALSE, order = 1:9, ...) {
Expand All @@ -209,7 +211,7 @@ palette_okabeito <- function(palette = "full_amber", reverse = FALSE, order = 1:

stopifnot(
"`order` must be a vector of integers." = is.numeric(order),
"All elements of `order` must be greater than 0 and less than 10." = all(order > 0 & order <= 9)
"All elements of `order` must be greater than 0 and less than 10." = order > 0 & order <= 9
)
pal <- pal[order]

Expand Down
2 changes: 1 addition & 1 deletion R/scale_color_pizza.R
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ pizza_palettes <- list(
#' @param palette Pizza type. Can be "margherita" (default), "margherita_crust",
#' "diavola" or "diavola_crust".
#' @param reverse Boolean indicating whether the palette should be reversed.
#' @param ... Additional arguments to pass to [`colorRampPalette()`][colorRampPalette].
#' @param ... Additional arguments to pass to [`grDevices::colorRampPalette()`].
#'
#' @details This function is usually not called directly, but from within
#' [`scale_color_pizza()`][scale_color_pizza].
Expand Down
2 changes: 0 additions & 2 deletions R/scale_color_see.R
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,6 @@ palette_see <- function(palette = "contrast", reverse = FALSE, ...) {





# helper -----------------------

.retrieve_palette <- function(palette, palette_list, reverse = FALSE, ...) {
Expand Down
Loading
Loading