diff --git a/DESCRIPTION b/DESCRIPTION index 3651c6bf6..80421fe40 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -41,8 +41,7 @@ Authors@R: person(given = "Matthew", family = "Smith", role = "rev", - email = "M.Smith3@napier.ac.uk", - comment = c(Twitter = "@SmithMatt90")), + email = "M.Smith3@napier.ac.uk"), person(given = "Jakob", family = "Bossek", role = "rev", @@ -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 diff --git a/NAMESPACE b/NAMESPACE index 7f5dce91b..793ca3c70 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -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) @@ -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) @@ -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) @@ -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) @@ -198,4 +202,5 @@ export(theme_lucid) export(theme_modern) export(theme_radar) export(theme_radar_dark) +export(tol_colors) import(ggplot2) diff --git a/R/scale_color_flat.R b/R/scale_color_flat.R index f6df99704..9fb817e12 100644 --- a/R/scale_color_flat.R +++ b/R/scale_color_flat.R @@ -45,7 +45,6 @@ scale_color_flat <- function(palette = "contrast", } - # Aliases ----------------------------------------------------------------- @@ -94,13 +93,9 @@ scale_colour_flat_c <- scale_color_flat_c scale_colour_flat_d <- scale_color_flat_d - - - # Fill -------------------------------------------------------------------- - #' @rdname scale_color_flat #' @export scale_fill_flat <- function(palette = "contrast", @@ -134,6 +129,7 @@ scale_fill_flat_d <- function(palette = "contrast", ) } + #' @rdname scale_color_flat #' @export scale_fill_flat_c <- function(palette = "contrast", @@ -151,14 +147,9 @@ scale_fill_flat_c <- function(palette = "contrast", } - - - # Palette -------------------------------------------------------------------- - - # The palette based on flat design colors: https://www.materialui.co/flatuicolors flat_colors_list <- c( `red` = "#e74c3c", @@ -205,8 +196,6 @@ flat_colors <- function(...) { } - - flat_palettes <- list( `full` = flat_colors(), `ice` = flat_colors("purple", "deep purple", "blue", "light blue"), @@ -239,9 +228,6 @@ flat_palettes <- list( - - - #' Flat UI color palette #' #' The palette based on [Flat UI](https://materialui.co/flatuicolors). @@ -251,10 +237,10 @@ flat_palettes <- list( #' `"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, ...) { diff --git a/R/scale_color_metro.R b/R/scale_color_metro.R index bc04ed6c4..576918b73 100644 --- a/R/scale_color_metro.R +++ b/R/scale_color_metro.R @@ -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 @@ -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" ) @@ -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", @@ -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", diff --git a/R/scale_color_okabeito.R b/R/scale_color_okabeito.R index 08710170e..1176978c1 100644 --- a/R/scale_color_okabeito.R +++ b/R/scale_color_okabeito.R @@ -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 @@ -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" ) @@ -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. @@ -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 @@ -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, ...) { @@ -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] diff --git a/R/scale_color_pizza.R b/R/scale_color_pizza.R index ecc1224ed..cb8c2aa4a 100644 --- a/R/scale_color_pizza.R +++ b/R/scale_color_pizza.R @@ -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]. diff --git a/R/scale_color_see.R b/R/scale_color_see.R index aa1382247..b85965309 100644 --- a/R/scale_color_see.R +++ b/R/scale_color_see.R @@ -240,8 +240,6 @@ palette_see <- function(palette = "contrast", reverse = FALSE, ...) { - - # helper ----------------------- .retrieve_palette <- function(palette, palette_list, reverse = FALSE, ...) { diff --git a/R/scale_color_tol.R b/R/scale_color_tol.R new file mode 100644 index 000000000..690395904 --- /dev/null +++ b/R/scale_color_tol.R @@ -0,0 +1,234 @@ +#' Paul Tol discrete/qualitative color palettes +#' +#' Tol (2021) presents a series of palettes built with mathematical principles +#' that are appropriate for diverse types of data. The colors in these schemes +#' are: +#' - Visually distinct for all people, including viewers with color vision +#' deficiencies +#' - Distinct from black and white +#' - Distinct on screen and paper, +#' - Cohesive; that is, they match well together +#' +#' Tol provides palettes appropriate to the 3 main types of data: +#' 1. Qualitative data – nominal or categorical data, where magnitude +#' differences are not relevant. +#' 2. Diverging data – data ordered between two extremes where the midpoint is +#' important. +#' 3. Sequential data – data ordered from low to high. +#' +#' This function provides the qualitative palettes, as well as discrete rainbow +#' sequential palettes. Available palettes for each type of data are: +#' - Qualitative: `bright`, `high-contrast`, `vibrant`, `muted`, +#' `medium-contrast`, `pale`, `dark`, `light`, `ground_cover` +#' - Diverging: `sunset`, `BuRd`, `PRGn` +#' - Sequential: `YlOrBr`, `iridescent`, `rainbow_discrete`, `rainbow_smooth` +#' +#' +#' +#' +#' +#' ## Colors for missing or invalid data +#' +#' A useful feature of Tol's diverging and sequential palettes is that he +#' provides a recommended color to use for data that fall outside the data range +#' represented by the color scale (e.g., for invalid or missing data). These +#' colors are chosen to be highly distinct from the main color palette. +#' +#' @inheritParams palette_tol_discrete +#' @inheritParams scale_color_flat +#' +#' @references +#' Tol, P. (2021). Colour schemes (SRON/EPS Technical Note No. 09-002; Version 3.2). +#' SRON. https://personal.sron.nl/~pault/data/colourschemes.pdf (Original work published 2009) +#' +#' @examples +#' library(ggplot2) +#' library(see) +#' +#' ggplot(iris, aes(x = Species, y = Sepal.Length, fill = Species)) + +#' geom_boxplot() + +#' theme_modern() + +#' scale_fill_okabeito() +#' +#' ggplot(iris, aes(x = Species, y = Sepal.Length, fill = Species)) + +#' geom_violin() + +#' theme_modern() + +#' scale_fill_oi(palette = "black_first") +#' +#' # for the original brighter yellow color suggested by Okabe and Ito +#' ggplot(iris, aes(x = Species, y = Sepal.Length, fill = Species)) + +#' geom_violin() + +#' theme_modern() + +#' scale_fill_oi(palette = "full") +#' +#' ggplot(iris, aes(x = Species, y = Sepal.Length, fill = Species)) + +#' geom_violin() + +#' theme_modern() + +#' scale_fill_oi(order = c(1, 5, 6, 2, 4, 3, 7)) +#' @export +scale_color_tol_discrete <- function(palette = "bright", reverse = FALSE, order = NULL, aesthetics = "color", ...) { + discrete_scale( + aesthetics = aesthetics, + palette = palette_tol_discrete(palette = palette, reverse = reverse, order = order), + ... + ) +} + +# Fill -------------------------------------------------------------------- + +#' @rdname scale_color_tol_discrete +#' @export +scale_fill_tol_discrete <- function(palette = "bright", reverse = FALSE, order = NULL, aesthetics = "fill", ...) { + discrete_scale( + aesthetics = aesthetics, + palette = palette_tol_discrete(palette = palette, reverse = reverse, order = order), + ... + ) +} + +# Aliases ----------------------------------------------------------------- + +#' @rdname scale_color_tol_discrete +#' @export +scale_colour_tol_discrete <- scale_color_tol_discrete + + +# Palette -------------------------------------------------------------------- + +tol_colors_discrete_list <- list( + bright = c(blue = "#4477AA", red = "#EE6677", green = "#228833", yellow = "#CCBB44", cyan = "#66CCEE", purple = "#AA3377", grey = "#BBBBBB"), + `high-contrast` = c(blue = "#004488", yellow = "#DDAA33", red = "#BB5566", black = "#000000", white = "#FFFFFF"), + vibrant = c(orange = "#EE7733", blue = "#0077BB", cyan = "#33BBEE", magenta = "#EE3377", red = "#CC3311", teal = "#009988", grey = "#BBBBBB"), + muted = c(rose = "#CC6677", indigo = "#332288", sand = "#DDCC77", green = "#117733", cyan = "#88CCEE", wine = "#882255", teal = "#44AA99", olive = "#999933", purple = "#AA4499", grey = "#DDDDDD"), + `medium-contrast` = c("light blue" = "#6699CC", "dark blue" = "#004488", "light yellow" = "#EECC66", "dark red" = "#994455", "dark yellow" = "#997700", "light red" = "#EE99AA", black = "#000000", white = "#FFFFFF"), + pale = c(blue = "#BBCCEE", cyan = "#CCEEFF", green = "#CCDDAA", yellow = "#EEEEBB", red = "#FFCCCC", grey = "#DDDDDD"), + dark = c(blue = "#222255", cyan = "#225555", green = "#225522", yellow = "#666633", red = "#663333", grey = "#555555"), + light = c(blue = "#77AADD", orange = "#EE8866", yellow = "#EEDD88", pink = "#FFAABB", cyan = "#99DDFF", mint = "#44BB99", pear = "#BBCC33", olive = "#AAAA00", grey = "#DDDDDD"), + # TODO: Finish rainbow color schemes + rainbow14 = c("3", "6", "9", "10", "12", "14", "15", "16", "17", "18", "20", "22", "24", "26" = "#DC050C", "grey"), + rainbow23 = c("1", "2", "4", "5", "7", "8", "9", "10", "11", "13", "14", "15", "16", "17", "18", "19", "21", "23", "25", "26" = "#DC050C", "27" = "#A5170E", "28" = "#72190E", "29" = "#42150A", grey = "#777777"), + ground_cover = c( + water = "#5566AA", "evergreen needleleaf forest" = "#117733", "deciduous needleleaf forest" = "#44AA66", + "mixed forest" = "#55AA22", "evergreen broadleaf forest" = "#668822", "deciduous broadleaf forest" = "#88BB55", + woodland = "#558877", "wooded grassland" = "#88BBAA", grassland = "#AADDCC", cropland = "#44AA88", + "closed shrubland" = "#DDCC66", "open shrubland" = "#FFDD44", "bare ground" = "#FFEE88", "urband and built up" = "#BB0011" + ) +) + +tol_colors_smooth_list <- list( + # Diverging + sunset = "#", + BuRd = NULL, + PRGn = NULL, + # Sequential + YlOrBr = NULL, + iridescent = NULL, + rainbow = NULL +) + + +#' Extract Paul Tol colors as hex codes +#' +#' Can be used to get the hex code of specific colors from the Paul Tol palettes. +#' Use `tol_colors()` and specify `palette` to see all available colors. +#' Note that for sequential palettes, only original (non-interpolated) colors are shown. +#' +#' @param ... Character names of colors. +#' @param palette Character name of palette. Can be: +#' - Qualitative: `"bright"`, `"high-contrast"`, `"vibrant"`, `"muted"`,` +#' "medium-contrast"`, `"pale"`, `"dark"`, `"light"`, `"ground_cover"` +#' - Diverging: `"sunset"`, `"BuRd"`, `"PRGn"` +#' - Sequential: `"YlOrBr"`, `"iridescent"`, `"rainbow_discrete"`, +#' `"rainbow_smooth"` +#' +#' @return A character vector with color-codes. +#' +#' @examples +#' tol_colors() +#' +#' tol_colors(c("red", "light blue", "yellow")) +#' +#' tol_colors(palette = "muted") +#' +#' tol_colors(c("red", "light blue", "yellow"), palette = "muted") +#' @export +tol_colors <- function(..., palette = "bright") { + cols <- c(...) + + if (!is.null(cols)) { + return(okabeito_colors_list[cols]) + } + + yellow_col <- if (isTRUE(amber)) "amber" else "yellow" + + if (isTRUE(original_names)) { + cols <- c("orange", "sky blue", "bluish green", yellow_col, "blue", "vermillion", "reddish purple", "grey", "black") + } else { + cols <- c("orange", "light blue", "green", yellow_col, "blue", "red", "purple", "grey", "black") + } + + if (isTRUE(black_first)) cols <- union("black", cols) + + okabeito_colors_list[cols] +} + + +#' Paul Tol's color palettes +#' +#' The palettes proposed by Tol (2021). +#' +#' @param palette Character name of palette. Can be: +#' - Qualitative: `"bright"`, `"high-contrast"`, `"vibrant"`, `"muted"`, +#' `"medium-contrast"`, `"pale"`, `"dark"`, `"light"`, `"ground_cover"` +#' - Diverging: `"sunset"`, `"BuRd"`, `"PRGn"` +#' - Sequential: `"YlOrBr"`, `"iridescent"`, `"rainbow_discrete"`, +#' - `"rainbow_smooth"` +#' @param reverse Boolean indicating whether the palette should be reversed. +#' @param order A vector of numbers indicating the order of colors to use +#' (default: `NULL` indicating to use all available colors in order). +#' @param ... For sequential palettes other than `rainbow_discrete`, additional +#' arguments to pass to [`grDevices::colorRampPalette()`]. +#' +#' @references +#' Tol, P. (2021). Colour schemes (SRON/EPS Technical Note No. 09-002; Version 3.2). +#' SRON. https://personal.sron.nl/~pault/data/colourschemes.pdf (Original work published 2009) +#' +#' @details This function is usually not called directly, but from within +#' [`scale_color_tol()`]. +#' +#' @export +palette_tol_discrete <- function(palette = "bright", reverse = FALSE, order = NULL, ...) { + if (!palette %in% names(tol_palettes)) { + msg <- c(paste0( + "Palette name not available. `palette` must be one of ", + datawizard::text_concatenate(names(okabeito_palettes), last = " or ", enclose = "`"), + "." + ), "Using default palette now.") + insight::format_warning(msg) + palette <- "full" + } + + pal <- okabeito_palettes[[palette]] + + stopifnot( + "`order` must be a vector of integers." = is.numeric(order), + "All elements of `order` must be greater than 0 and less than 10." = order > 0 & order <= 9 + ) + pal <- pal[order] + + if (reverse) pal <- rev(pal) + + function(n) { + if (n > length(pal)) { + insight::format_warning( + "The number of colors requested `n` is too large.", + paste0("The maximum number of colors is ", length(pal), "."), + paste0("Returning a palette with ", length(pal), " colors.") + ) + n <- length(pal) + } + unname(pal[seq_len(n)]) + } +} diff --git a/inst/WORDLIST b/inst/WORDLIST index 067baec4b..6819b3be3 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -25,10 +25,13 @@ ORCID Okabe Polychoric SEM +SRON Shachar SmithMatt Springer Tetrachoric +Tol +Tol's UI VIF Verlag @@ -106,6 +109,7 @@ rescaled rstanarm sjPlot strengejacke +sron subfigures survminer tidymv diff --git a/man/okabeito_colors.Rd b/man/okabeito_colors.Rd index 9ed503327..a936dccd7 100644 --- a/man/okabeito_colors.Rd +++ b/man/okabeito_colors.Rd @@ -14,12 +14,12 @@ oi_colors(..., original_names = FALSE, black_first = FALSE, amber = TRUE) \item{original_names}{Logical. Should the colors be named using the original names used by Okabe and Ito (2008), such as "vermillion" (\code{TRUE}), or -simplified names, such as "red" (\code{FALSE}, default)? -Only used if no colors are specified (to see all available colors).} +simplified names, such as "red" (\code{FALSE}, default)? Only used if no colors +are specified (to see all available colors).} -\item{black_first}{Logical. Should black be first (\code{TRUE}) or last (\code{FALSE}, default) -in the color palette? Only used if no colors are specified (to see all -available colors).} +\item{black_first}{Logical. Should black be first (\code{TRUE}) or last (\code{FALSE}, +default) in the color palette? Only used if no colors are specified (to see +all available colors).} \item{amber}{If amber color should replace yellow in the palette.} } diff --git a/man/palette_bluebrown.Rd b/man/palette_bluebrown.Rd index 1711d7507..a40fb42eb 100644 --- a/man/palette_bluebrown.Rd +++ b/man/palette_bluebrown.Rd @@ -14,7 +14,7 @@ or \code{black_first_original}.} \item{reverse}{Boolean indicating whether the palette should be reversed.} -\item{...}{Additional arguments to pass to \code{\link[=colorRampPalette]{colorRampPalette()}}.} +\item{...}{Additional arguments to pass to \code{\link[grDevices:colorRamp]{grDevices::colorRampPalette()}}.} } \description{ The palette based on blue-brown colors. diff --git a/man/palette_colorhex.Rd b/man/palette_colorhex.Rd index d140b42b9..932b8f912 100644 --- a/man/palette_colorhex.Rd +++ b/man/palette_colorhex.Rd @@ -13,7 +13,7 @@ For example, \code{1014416} for the \item{reverse}{Boolean indicating whether the palette should be reversed.} -\item{...}{Additional arguments to pass to \code{\link[=colorRampPalette]{colorRampPalette()}}.} +\item{...}{Additional arguments to pass to \code{\link[grDevices:colorRamp]{grDevices::colorRampPalette()}}.} } \description{ This function downloads a requested color palette from \url{https://www.color-hex.com/}. diff --git a/man/palette_flat.Rd b/man/palette_flat.Rd index a1824c259..c6de6d82f 100644 --- a/man/palette_flat.Rd +++ b/man/palette_flat.Rd @@ -14,7 +14,7 @@ or \code{black_first_original}.} \item{reverse}{Boolean indicating whether the palette should be reversed.} -\item{...}{Additional arguments to pass to \code{\link[=colorRampPalette]{colorRampPalette()}}.} +\item{...}{Additional arguments to pass to \code{\link[grDevices:colorRamp]{grDevices::colorRampPalette()}}.} } \description{ The palette based on \href{https://materialui.co/flatuicolors}{Flat UI}. diff --git a/man/palette_material.Rd b/man/palette_material.Rd index a09d728a4..40b7e0728 100644 --- a/man/palette_material.Rd +++ b/man/palette_material.Rd @@ -14,7 +14,7 @@ or \code{black_first_original}.} \item{reverse}{Boolean indicating whether the palette should be reversed.} -\item{...}{Additional arguments to pass to \code{\link[=colorRampPalette]{colorRampPalette()}}.} +\item{...}{Additional arguments to pass to \code{\link[grDevices:colorRamp]{grDevices::colorRampPalette()}}.} } \description{ The palette based on \href{https://materialui.co/}{material design colors}. diff --git a/man/palette_metro.Rd b/man/palette_metro.Rd index d7173bf0e..288ad6515 100644 --- a/man/palette_metro.Rd +++ b/man/palette_metro.Rd @@ -14,7 +14,7 @@ or \code{black_first_original}.} \item{reverse}{Boolean indicating whether the palette should be reversed.} -\item{...}{Additional arguments to pass to \code{\link[=colorRampPalette]{colorRampPalette()}}.} +\item{...}{Additional arguments to pass to \code{\link[grDevices:colorRamp]{grDevices::colorRampPalette()}}.} } \description{ The palette based on \href{https://materialui.co/metrocolors}{Metro colors}. diff --git a/man/palette_okabeito.Rd b/man/palette_okabeito.Rd index 776dd388c..69b1f0b4e 100644 --- a/man/palette_okabeito.Rd +++ b/man/palette_okabeito.Rd @@ -20,14 +20,14 @@ or \code{black_first_original}.} \item{order}{A vector of numbers from 1 to 9 indicating the order of colors to use (default: \code{1:9})} -\item{...}{Additional arguments to pass to \code{\link[=colorRampPalette]{colorRampPalette()}}.} +\item{...}{Additional arguments to pass to \code{\link[grDevices:colorRamp]{grDevices::colorRampPalette()}}.} } \description{ -The palette based proposed by Okabe and Ito (2008). +The palette based on Okabe and Ito (2008). } \details{ This function is usually not called directly, but from within -\code{\link[=scale_color_material]{scale_color_material()}}. +\code{\link[=scale_color_okabeito]{scale_color_okabeito()}}. } \references{ Okabe, M., & Ito, K. (2008). Color universal design (CUD): diff --git a/man/palette_pizza.Rd b/man/palette_pizza.Rd index 164e40c09..0e4d7a2bb 100644 --- a/man/palette_pizza.Rd +++ b/man/palette_pizza.Rd @@ -12,7 +12,7 @@ palette_pizza(palette = "margherita", reverse = FALSE, ...) \item{reverse}{Boolean indicating whether the palette should be reversed.} -\item{...}{Additional arguments to pass to \code{\link[=colorRampPalette]{colorRampPalette()}}.} +\item{...}{Additional arguments to pass to \code{\link[grDevices:colorRamp]{grDevices::colorRampPalette()}}.} } \description{ The palette based on authentic neapolitan pizzas. diff --git a/man/palette_see.Rd b/man/palette_see.Rd index 48937075e..831aeb9b1 100644 --- a/man/palette_see.Rd +++ b/man/palette_see.Rd @@ -14,7 +14,7 @@ or \code{black_first_original}.} \item{reverse}{Boolean indicating whether the palette should be reversed.} -\item{...}{Additional arguments to pass to \code{\link[=colorRampPalette]{colorRampPalette()}}.} +\item{...}{Additional arguments to pass to \code{\link[grDevices:colorRamp]{grDevices::colorRampPalette()}}.} } \description{ See design color palette diff --git a/man/palette_social.Rd b/man/palette_social.Rd index 45d62cfee..04cf945fe 100644 --- a/man/palette_social.Rd +++ b/man/palette_social.Rd @@ -14,7 +14,7 @@ or \code{black_first_original}.} \item{reverse}{Boolean indicating whether the palette should be reversed.} -\item{...}{Additional arguments to pass to \code{\link[=colorRampPalette]{colorRampPalette()}}.} +\item{...}{Additional arguments to pass to \code{\link[grDevices:colorRamp]{grDevices::colorRampPalette()}}.} } \description{ The palette based \href{https://materialui.co/socialcolors}{Social colors}. diff --git a/man/palette_tol_discrete.Rd b/man/palette_tol_discrete.Rd new file mode 100644 index 000000000..9d4eada6e --- /dev/null +++ b/man/palette_tol_discrete.Rd @@ -0,0 +1,37 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/scale_color_tol.R +\name{palette_tol_discrete} +\alias{palette_tol_discrete} +\title{Paul Tol's color palettes} +\usage{ +palette_tol_discrete(palette = "bright", reverse = FALSE, order = NULL, ...) +} +\arguments{ +\item{palette}{Character name of palette. Can be: +\itemize{ +\item Qualitative: \code{"bright"}, \code{"high-contrast"}, \code{"vibrant"}, \code{"muted"}, +\code{"medium-contrast"}, \code{"pale"}, \code{"dark"}, \code{"light"}, \code{"ground_cover"} +\item Diverging: \code{"sunset"}, \code{"BuRd"}, \code{"PRGn"} +\item Sequential: \code{"YlOrBr"}, \code{"iridescent"}, \code{"rainbow_discrete"}, +\item \code{"rainbow_smooth"} +}} + +\item{reverse}{Boolean indicating whether the palette should be reversed.} + +\item{order}{A vector of numbers indicating the order of colors to use +(default: \code{NULL} indicating to use all available colors in order).} + +\item{...}{For sequential palettes other than \code{rainbow_discrete}, additional +arguments to pass to \code{\link[grDevices:colorRamp]{grDevices::colorRampPalette()}}.} +} +\description{ +The palettes proposed by Tol (2021). +} +\details{ +This function is usually not called directly, but from within +\code{\link[=scale_color_tol]{scale_color_tol()}}. +} +\references{ +Tol, P. (2021). Colour schemes (SRON/EPS Technical Note No. 09-002; Version 3.2). +SRON. https://personal.sron.nl/~pault/data/colourschemes.pdf (Original work published 2009) +} diff --git a/man/scale_color_bluebrown.Rd b/man/scale_color_bluebrown.Rd index e84531020..9e1a7598a 100644 --- a/man/scale_color_bluebrown.Rd +++ b/man/scale_color_bluebrown.Rd @@ -97,7 +97,7 @@ or \code{black_first_original}.} \item{aesthetics}{A vector of names of the aesthetics that this scale should be applied to (e.g., \code{c('color', 'fill')}).} -\item{...}{Additional arguments to pass to \code{\link[=colorRampPalette]{colorRampPalette()}}.} +\item{...}{Additional arguments to pass to \code{\link[grDevices:colorRamp]{grDevices::colorRampPalette()}}.} } \description{ A blue-brown color palette. Use \code{scale_color_bluebrown_d()} for diff --git a/man/scale_color_colorhex.Rd b/man/scale_color_colorhex.Rd index 261048c82..b810a24dd 100644 --- a/man/scale_color_colorhex.Rd +++ b/man/scale_color_colorhex.Rd @@ -96,7 +96,7 @@ For example, \code{1014416} for the \item{aesthetics}{A vector of names of the aesthetics that this scale should be applied to (e.g., \code{c('color', 'fill')}).} -\item{...}{Additional arguments to pass to \code{\link[=colorRampPalette]{colorRampPalette()}}.} +\item{...}{Additional arguments to pass to \code{\link[grDevices:colorRamp]{grDevices::colorRampPalette()}}.} } \description{ This function creates color scales based on palettes from \url{https://www.color-hex.com/}. diff --git a/man/scale_color_material.Rd b/man/scale_color_material.Rd index 1832b6a17..0a72f2d91 100644 --- a/man/scale_color_material.Rd +++ b/man/scale_color_material.Rd @@ -97,7 +97,7 @@ or \code{black_first_original}.} \item{aesthetics}{A vector of names of the aesthetics that this scale should be applied to (e.g., \code{c('color', 'fill')}).} -\item{...}{Additional arguments to pass to \code{\link[=colorRampPalette]{colorRampPalette()}}.} +\item{...}{Additional arguments to pass to \code{\link[grDevices:colorRamp]{grDevices::colorRampPalette()}}.} } \description{ The palette based on \href{https://materialui.co/}{material design colors}. Use \code{scale_color_material_d()} for diff --git a/man/scale_color_metro.Rd b/man/scale_color_metro.Rd index 464e04152..f6dd6724e 100644 --- a/man/scale_color_metro.Rd +++ b/man/scale_color_metro.Rd @@ -97,12 +97,12 @@ or \code{black_first_original}.} \item{aesthetics}{A vector of names of the aesthetics that this scale should be applied to (e.g., \code{c('color', 'fill')}).} -\item{...}{Additional arguments to pass to \code{\link[=colorRampPalette]{colorRampPalette()}}.} +\item{...}{Additional arguments to pass to \code{\link[grDevices:colorRamp]{grDevices::colorRampPalette()}}.} } \description{ The palette based on Metro \href{https://materialui.co/metrocolors}{Metro colors}. -Use \code{scale_color_metro_d} for \emph{discrete} categories and -\code{scale_color_metro_c} for a \emph{continuous} scale. +Use \code{scale_color_metro_d} for \emph{discrete} categories and \code{scale_color_metro_c} +for a \emph{continuous} scale. } \examples{ library(ggplot2) diff --git a/man/scale_color_okabeito.Rd b/man/scale_color_okabeito.Rd index a5bcb4e7f..913c7fd3c 100644 --- a/man/scale_color_okabeito.Rd +++ b/man/scale_color_okabeito.Rd @@ -71,7 +71,7 @@ or \code{black_first_original}.} \item{aesthetics}{A vector of names of the aesthetics that this scale should be applied to (e.g., \code{c('color', 'fill')}).} -\item{...}{Additional arguments to pass to \code{\link[=colorRampPalette]{colorRampPalette()}}.} +\item{...}{Additional arguments to pass to \code{\link[grDevices:colorRamp]{grDevices::colorRampPalette()}}.} } \description{ The Okabe-Ito color palette was proposed by Okabe and Ito (2008) as a @@ -96,6 +96,7 @@ palettes \code{"full_original"} or \code{"black_first_original"}. The Okabe-Ito palette is only available as a discrete palette. For color-accessible continuous variables, consider +\link[=scale_color_tol_discrete]{Paul Tol's palettes} or \link[ggplot2:scale_viridis]{the viridis palettes}. } \examples{ diff --git a/man/scale_color_pizza.Rd b/man/scale_color_pizza.Rd index aff451f23..671948fd3 100644 --- a/man/scale_color_pizza.Rd +++ b/man/scale_color_pizza.Rd @@ -95,7 +95,7 @@ scale_fill_pizza_c( \item{aesthetics}{A vector of names of the aesthetics that this scale should be applied to (e.g., \code{c('color', 'fill')}).} -\item{...}{Additional arguments to pass to \code{\link[=colorRampPalette]{colorRampPalette()}}.} +\item{...}{Additional arguments to pass to \code{\link[grDevices:colorRamp]{grDevices::colorRampPalette()}}.} } \description{ The palette based on authentic neapolitan pizzas. diff --git a/man/scale_color_see.Rd b/man/scale_color_see.Rd index d8aa82fa5..e3372fd7f 100644 --- a/man/scale_color_see.Rd +++ b/man/scale_color_see.Rd @@ -97,7 +97,7 @@ or \code{black_first_original}.} \item{aesthetics}{A vector of names of the aesthetics that this scale should be applied to (e.g., \code{c('color', 'fill')}).} -\item{...}{Additional arguments to pass to \code{\link[=colorRampPalette]{colorRampPalette()}}.} +\item{...}{Additional arguments to pass to \code{\link[grDevices:colorRamp]{grDevices::colorRampPalette()}}.} } \description{ The See color palette. Use \code{scale_color_see_d()} for \emph{discrete} diff --git a/man/scale_color_social.Rd b/man/scale_color_social.Rd index e013e7a86..426d57125 100644 --- a/man/scale_color_social.Rd +++ b/man/scale_color_social.Rd @@ -97,7 +97,7 @@ or \code{black_first_original}.} \item{aesthetics}{A vector of names of the aesthetics that this scale should be applied to (e.g., \code{c('color', 'fill')}).} -\item{...}{Additional arguments to pass to \code{\link[=colorRampPalette]{colorRampPalette()}}.} +\item{...}{Additional arguments to pass to \code{\link[grDevices:colorRamp]{grDevices::colorRampPalette()}}.} } \description{ The palette based \href{https://materialui.co/socialcolors}{Social colors}. diff --git a/man/scale_color_tol_discrete.Rd b/man/scale_color_tol_discrete.Rd new file mode 100644 index 000000000..64ce0c09f --- /dev/null +++ b/man/scale_color_tol_discrete.Rd @@ -0,0 +1,128 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/scale_color_tol.R +\name{scale_color_tol_discrete} +\alias{scale_color_tol_discrete} +\alias{scale_fill_tol_discrete} +\alias{scale_colour_tol_discrete} +\title{Paul Tol discrete/qualitative color palettes} +\usage{ +scale_color_tol_discrete( + palette = "bright", + reverse = FALSE, + order = NULL, + aesthetics = "color", + ... +) + +scale_fill_tol_discrete( + palette = "bright", + reverse = FALSE, + order = NULL, + aesthetics = "fill", + ... +) + +scale_colour_tol_discrete( + palette = "bright", + reverse = FALSE, + order = NULL, + aesthetics = "color", + ... +) +} +\arguments{ +\item{palette}{Character name of palette. Can be: +\itemize{ +\item Qualitative: \code{"bright"}, \code{"high-contrast"}, \code{"vibrant"}, \code{"muted"}, +\code{"medium-contrast"}, \code{"pale"}, \code{"dark"}, \code{"light"}, \code{"ground_cover"} +\item Diverging: \code{"sunset"}, \code{"BuRd"}, \code{"PRGn"} +\item Sequential: \code{"YlOrBr"}, \code{"iridescent"}, \code{"rainbow_discrete"}, +\item \code{"rainbow_smooth"} +}} + +\item{reverse}{Boolean indicating whether the palette should be reversed.} + +\item{order}{A vector of numbers indicating the order of colors to use +(default: \code{NULL} indicating to use all available colors in order).} + +\item{aesthetics}{A vector of names of the aesthetics that this scale +should be applied to (e.g., \code{c('color', 'fill')}).} + +\item{...}{For sequential palettes other than \code{rainbow_discrete}, additional +arguments to pass to \code{\link[grDevices:colorRamp]{grDevices::colorRampPalette()}}.} +} +\description{ +Tol (2021) presents a series of palettes built with mathematical principles +that are appropriate for diverse types of data. The colors in these schemes +are: +\itemize{ +\item Visually distinct for all people, including viewers with color vision +deficiencies +\item Distinct from black and white +\item Distinct on screen and paper, +\item Cohesive; that is, they match well together +} +} +\details{ +Tol provides palettes appropriate to the 3 main types of data: +\enumerate{ +\item Qualitative data – nominal or categorical data, where magnitude +differences are not relevant. +\item Diverging data – data ordered between two extremes where the midpoint is +important. +\item Sequential data – data ordered from low to high. +} + +This function provides the qualitative palettes, as well as discrete rainbow +sequential palettes. Available palettes for each type of data are: +\itemize{ +\item Qualitative: \code{bright}, \code{high-contrast}, \code{vibrant}, \code{muted}, +\code{medium-contrast}, \code{pale}, \code{dark}, \code{light}, \code{ground_cover} +\item Diverging: \code{sunset}, \code{BuRd}, \code{PRGn} +\item Sequential: \code{YlOrBr}, \code{iridescent}, \code{rainbow_discrete}, \code{rainbow_smooth} +}\if{html}{\out{ + +}} +\if{html}{\out{ + +}} + +\subsection{Colors for missing or invalid data}{ + +A useful feature of Tol's diverging and sequential palettes is that he +provides a recommended color to use for data that fall outside the data range +represented by the color scale (e.g., for invalid or missing data). These +colors are chosen to be highly distinct from the main color palette. +} +} +\examples{ +library(ggplot2) +library(see) + +ggplot(iris, aes(x = Species, y = Sepal.Length, fill = Species)) + + geom_boxplot() + + theme_modern() + + scale_fill_okabeito() + +ggplot(iris, aes(x = Species, y = Sepal.Length, fill = Species)) + + geom_violin() + + theme_modern() + + scale_fill_oi(palette = "black_first") + +# for the original brighter yellow color suggested by Okabe and Ito +ggplot(iris, aes(x = Species, y = Sepal.Length, fill = Species)) + + geom_violin() + + theme_modern() + + scale_fill_oi(palette = "full") + +ggplot(iris, aes(x = Species, y = Sepal.Length, fill = Species)) + + geom_violin() + + theme_modern() + + scale_fill_oi(order = c(1, 5, 6, 2, 4, 3, 7)) +} +\references{ +Tol, P. (2021). Colour schemes (SRON/EPS Technical Note No. 09-002; Version 3.2). +SRON. https://personal.sron.nl/~pault/data/colourschemes.pdf (Original work published 2009) +} diff --git a/man/see-package.Rd b/man/see-package.Rd index 33bc37094..4e2cea88a 100644 --- a/man/see-package.Rd +++ b/man/see-package.Rd @@ -25,13 +25,13 @@ Useful links: } \author{ -\strong{Maintainer}: Indrajeet Patil \email{patilindrajeet.science@gmail.com} (\href{https://orcid.org/0000-0003-1995-6531}{ORCID}) (@patilindrajeets) +\strong{Maintainer}: Indrajeet Patil \email{patilindrajeet.science@gmail.com} (\href{https://orcid.org/0000-0003-1995-6531}{ORCID}) Authors: \itemize{ - \item Daniel Lüdecke \email{d.luedecke@uke.de} (\href{https://orcid.org/0000-0002-8895-3206}{ORCID}) (@strengejacke) [contributor] - \item Dominique Makowski \email{dom.makowski@gmail.com} (\href{https://orcid.org/0000-0001-5375-9967}{ORCID}) (@Dom_Makowski) [inventor] - \item Mattan S. Ben-Shachar \email{matanshm@post.bgu.ac.il} (\href{https://orcid.org/0000-0002-4287-4801}{ORCID}) (@mattansb) [contributor] + \item Daniel Lüdecke \email{d.luedecke@uke.de} (\href{https://orcid.org/0000-0002-8895-3206}{ORCID}) [contributor] + \item Dominique Makowski \email{dom.makowski@gmail.com} (\href{https://orcid.org/0000-0001-5375-9967}{ORCID}) [inventor] + \item Mattan S. Ben-Shachar \email{matanshm@post.bgu.ac.il} (\href{https://orcid.org/0000-0002-4287-4801}{ORCID}) [contributor] \item Brenton M. Wiernik \email{brenton@wiernik.org} (\href{https://orcid.org/0000-0001-9560-6336}{ORCID}) [contributor] \item Philip Waggoner \email{philip.waggoner@gmail.com} (\href{https://orcid.org/0000-0002-7825-7573}{ORCID}) [contributor] } @@ -39,8 +39,8 @@ Authors: Other contributors: \itemize{ \item Jeffrey R. Stevens \email{jeffrey.r.stevens@gmail.com} (\href{https://orcid.org/0000-0003-2375-1360}{ORCID}) [contributor] - \item Matthew Smith \email{M.Smith3@napier.ac.uk} (@SmithMatt90) [reviewer] - \item Jakob Bossek \email{bossek@wi.uni-muenster.de} (@BossekJakob) [reviewer] + \item Matthew Smith \email{M.Smith3@napier.ac.uk} [reviewer] + \item Jakob Bossek \email{bossek@wi.uni-muenster.de} [reviewer] } } diff --git a/man/tol_colors.Rd b/man/tol_colors.Rd new file mode 100644 index 000000000..a8859a00a --- /dev/null +++ b/man/tol_colors.Rd @@ -0,0 +1,36 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/scale_color_tol.R +\name{tol_colors} +\alias{tol_colors} +\title{Extract Paul Tol colors as hex codes} +\usage{ +tol_colors(..., palette = "bright") +} +\arguments{ +\item{...}{Character names of colors.} + +\item{palette}{Character name of palette. Can be: +\itemize{ +\item Qualitative: \code{"bright"}, \code{"high-contrast"}, \code{"vibrant"}, \code{"muted"},\code{ "medium-contrast"}, \code{"pale"}, \code{"dark"}, \code{"light"}, \code{"ground_cover"} +\item Diverging: \code{"sunset"}, \code{"BuRd"}, \code{"PRGn"} +\item Sequential: \code{"YlOrBr"}, \code{"iridescent"}, \code{"rainbow_discrete"}, +\code{"rainbow_smooth"} +}} +} +\value{ +A character vector with color-codes. +} +\description{ +Can be used to get the hex code of specific colors from the Paul Tol palettes. +Use \code{tol_colors()} and specify \code{palette} to see all available colors. +Note that for sequential palettes, only original (non-interpolated) colors are shown. +} +\examples{ +tol_colors() + +tol_colors(c("red", "light blue", "yellow")) + +tol_colors(palette = "muted") + +tol_colors(c("red", "light blue", "yellow"), palette = "muted") +}