| 1 |
# PALETTES |
|
| 2 | ||
| 3 |
# Palettes ===================================================================== |
|
| 4 |
## Color ----------------------------------------------------------------------- |
|
| 5 |
#' Color Mapping |
|
| 6 |
#' |
|
| 7 |
#' Maps values to colors. |
|
| 8 |
#' @param scheme A [`character`] string giving the name of the scheme to be |
|
| 9 |
#' used (see [color()]). |
|
| 10 |
#' @param domain A [`numeric`] range or a vector of categorical data specifying |
|
| 11 |
#' the possible values that can be mapped. |
|
| 12 |
#' @param midpoint A length-one [`numeric`] vector specifying the mid-point of |
|
| 13 |
#' input range. |
|
| 14 |
#' @param ordered A [`logical`] scalar: should the levels be treated as already |
|
| 15 |
#' in the correct order? |
|
| 16 |
#' @param missing The color to return for `NA` values. |
|
| 17 |
#' @param ... Further parameters to be passed to [color()]. |
|
| 18 |
#' @details |
|
| 19 |
#' A wrapper around `palette_color_continuous()` and |
|
| 20 |
#' `palette_color_discrete()`. |
|
| 21 |
#' @return |
|
| 22 |
#' A palette [`function`] that when called with a single argument returns |
|
| 23 |
#' a [`character`] vector of colors. |
|
| 24 |
#' @example inst/examples/ex-palette-color.R |
|
| 25 |
#' @family palettes |
|
| 26 |
#' @export |
|
| 27 |
palette_color_picker <- function(scheme, domain = NULL, midpoint = NULL, |
|
| 28 |
ordered = FALSE, missing = NULL, ...) {
|
|
| 29 | ||
| 30 | 6x |
scheme <- color(scheme, ...) |
| 31 | 6x |
col <- scheme() |
| 32 | 6x |
miss <- missing %||% attr(scheme, "missing") |
| 33 | 3x |
if (is.na(miss)) miss <- "#DDDDDD" |
| 34 | ||
| 35 | 6x |
quali <- attr(scheme, "type") == "qualitative" |
| 36 | 6x |
if (quali) {
|
| 37 | 3x |
fun <- palette_color_discrete( |
| 38 | 3x |
colors = col, |
| 39 | 3x |
domain = domain, |
| 40 | 3x |
ordered = ordered, |
| 41 | 3x |
missing = miss |
| 42 |
) |
|
| 43 |
} else {
|
|
| 44 | 3x |
fun <- palette_color_continuous( |
| 45 | 3x |
colors = col, |
| 46 | 3x |
domain = domain, |
| 47 | 3x |
midpoint = midpoint, |
| 48 | 3x |
missing = miss |
| 49 |
) |
|
| 50 |
} |
|
| 51 | ||
| 52 | 6x |
fun |
| 53 |
} |
|
| 54 | ||
| 55 |
#' @export |
|
| 56 |
#' @rdname palette_color_picker |
|
| 57 |
palette_colour_picker <- palette_color_picker |
|
| 58 | ||
| 59 |
#' Color Mapping (continuous) |
|
| 60 |
#' |
|
| 61 |
#' Maps continuous values to an interpolated colors gradient. |
|
| 62 |
#' @param colors A vector of colors or a [`function`] that when called with a |
|
| 63 |
#' single argument (an integer specifying the number of colors) returns a |
|
| 64 |
#' vector of colors. If `NULL` (the default), uses *YlOrRd*. |
|
| 65 |
#' @param domain A [`numeric`] range specifying the possible values that can be |
|
| 66 |
#' mapped. |
|
| 67 |
#' @param midpoint A length-one [`numeric`] vector specifying the mid-point of |
|
| 68 |
#' input range. |
|
| 69 |
#' @param missing The color to return for `NA` values. |
|
| 70 |
#' @return |
|
| 71 |
#' A palette [`function`] that when called with a single argument |
|
| 72 |
#' (a [`numeric`] vector of continuous values) returns a [`character`] vector |
|
| 73 |
#' of colors. |
|
| 74 |
#' @seealso [grDevices::colorRamp()] |
|
| 75 |
#' @example inst/examples/ex-palette-continuous.R |
|
| 76 |
#' @family palettes |
|
| 77 |
#' @export |
|
| 78 |
palette_color_continuous <- function(colors = NULL, domain = NULL, |
|
| 79 |
midpoint = NULL, missing = "#DDDDDD") {
|
|
| 80 | ||
| 81 | 14x |
force(colors) |
| 82 | 14x |
force(domain) |
| 83 | 14x |
force(midpoint) |
| 84 | 14x |
force(missing) |
| 85 | ||
| 86 | 14x |
function(x, ...) {
|
| 87 | 14x |
need_continuous(x) |
| 88 | ||
| 89 | 12x |
rng <- if (!is.null(domain)) range(domain, finite = TRUE) else range(x, finite = TRUE) |
| 90 | 12x |
if (!is.null(midpoint) && is.numeric(midpoint)) {
|
| 91 | 1x |
x <- scale_midpoint(x, to = c(0, 1), from = rng, midpoint = midpoint) |
| 92 |
} else {
|
|
| 93 | 11x |
x <- scale_range(x, to = c(0, 1), from = rng) |
| 94 |
} |
|
| 95 | ||
| 96 | 12x |
out <- x < 0 | x > 1 |
| 97 | 12x |
if (any(out, na.rm = TRUE)) {
|
| 98 | 2x |
x[out] <- NA |
| 99 | 2x |
warning(tr_("Some values were outside the color scale."), call. = FALSE)
|
| 100 |
} |
|
| 101 | ||
| 102 | 12x |
OK <- !is.na(x) |
| 103 | 12x |
if (is.null(colors)) {
|
| 104 | 1x |
colors <- color(palette = "YlOrBr")(9) |
| 105 |
} |
|
| 106 | 12x |
if (is.function(colors)) {
|
| 107 | 1x |
colors <- colors(9) |
| 108 |
} |
|
| 109 | 12x |
colors <- grDevices::colorRamp(colors)(x[OK], ...) |
| 110 | ||
| 111 | 12x |
col <- rep(missing, length(x)) |
| 112 | 12x |
col[OK] <- grDevices::rgb(colors, maxColorValue = 255) |
| 113 | 12x |
col |
| 114 |
} |
|
| 115 |
} |
|
| 116 | ||
| 117 |
#' @export |
|
| 118 |
#' @rdname palette_color_continuous |
|
| 119 |
palette_colour_continuous <- palette_color_continuous |
|
| 120 | ||
| 121 |
#' Color Mapping (discrete) |
|
| 122 |
#' |
|
| 123 |
#' Maps categorical values to colors. |
|
| 124 |
#' @param colors A vector of colors or a [`function`] that when called with a |
|
| 125 |
#' single argument (an integer specifying the number of colors) returns a |
|
| 126 |
#' vector of colors. If `NULL` (the default), uses *discrete rainbow*. |
|
| 127 |
#' @param domain A vector of categorical data specifying the possible values |
|
| 128 |
#' that can be mapped. |
|
| 129 |
#' @param ordered A [`logical`] scalar: should the levels be treated as already |
|
| 130 |
#' in the correct order? |
|
| 131 |
#' @param missing The color to return for `NA` values. |
|
| 132 |
#' @return |
|
| 133 |
#' A palette [`function`] that when called with a single argument |
|
| 134 |
#' (a vector of categorical values) returns a [`character`] vector of colors. |
|
| 135 |
#' @example inst/examples/ex-palette-discrete.R |
|
| 136 |
#' @family palettes |
|
| 137 |
#' @export |
|
| 138 |
palette_color_discrete <- function(colors = NULL, domain = NULL, |
|
| 139 |
ordered = FALSE, missing = "#DDDDDD") {
|
|
| 140 | ||
| 141 | 15x |
force(colors) |
| 142 | 15x |
force(domain) |
| 143 | 15x |
force(ordered) |
| 144 | 15x |
force(missing) |
| 145 | ||
| 146 |
## If named colors, override user settings |
|
| 147 | 15x |
if (!is.null(names(colors))) {
|
| 148 | 1x |
domain <- names(colors) |
| 149 | 1x |
ordered <- TRUE |
| 150 |
} |
|
| 151 | ||
| 152 | 15x |
function(x, ...) {
|
| 153 | 15x |
need_discrete(x) |
| 154 | ||
| 155 | 15x |
domain <- make_levels(x, levels = domain, ordered = ordered) |
| 156 | 15x |
n <- length(domain) |
| 157 | 15x |
x <- match(as.character(x), domain) |
| 158 | ||
| 159 | 15x |
OK <- !is.na(x) |
| 160 | 15x |
if (is.null(colors)) {
|
| 161 | 2x |
colors <- color(palette = "discreterainbow")(n) |
| 162 |
} |
|
| 163 | 15x |
if (is.function(colors)) {
|
| 164 | 1x |
colors <- colors(n) |
| 165 |
} |
|
| 166 | ||
| 167 | 15x |
m <- length(colors) |
| 168 | 15x |
if (m < n) {
|
| 169 | 3x |
msg_m <- sprintf(ngettext(m, "Only %d color was specified", "Only %d colors were specified"), m) |
| 170 | 3x |
msg_n <- sprintf(ngettext(n, "(%d is required)", "(%d are required)"), n) |
| 171 | 3x |
warning(sprintf("%s %s.", msg_m, msg_n), call. = FALSE)
|
| 172 |
} |
|
| 173 | 15x |
col <- colors[x] |
| 174 | 15x |
col[!OK] <- missing |
| 175 | 15x |
col |
| 176 |
} |
|
| 177 |
} |
|
| 178 | ||
| 179 |
#' @export |
|
| 180 |
#' @rdname palette_color_discrete |
|
| 181 |
palette_colour_discrete <- palette_color_discrete |
|
| 182 | ||
| 183 |
## Symbol ---------------------------------------------------------------------- |
|
| 184 |
#' Symbol Mapping |
|
| 185 |
#' |
|
| 186 |
#' @param symbols,types A vector of symbols or line types. |
|
| 187 |
#' @param domain A vector of categorical data specifying the possible values |
|
| 188 |
#' that can be mapped. |
|
| 189 |
#' @param ordered A [`logical`] scalar: should the levels be treated as already |
|
| 190 |
#' in the correct order? |
|
| 191 |
#' @param ... Currently not used. |
|
| 192 |
#' @return |
|
| 193 |
#' A palette [`function`] that when called with a single argument |
|
| 194 |
#' (a [`character`] vector of categorical values) returns a vector of symbols. |
|
| 195 |
#' @example inst/examples/ex-palette-discrete.R |
|
| 196 |
#' @family palettes |
|
| 197 |
#' @export |
|
| 198 |
palette_shape <- function(symbols = NULL, domain = NULL, ordered = FALSE, ...) {
|
|
| 199 | ||
| 200 | 9x |
force(symbols) |
| 201 | 9x |
force(domain) |
| 202 | 9x |
force(ordered) |
| 203 | ||
| 204 |
## If named symbol, override user settings |
|
| 205 | 9x |
if (!is.null(names(symbols))) {
|
| 206 | 1x |
domain <- names(symbols) |
| 207 | 1x |
ordered <- TRUE |
| 208 |
} |
|
| 209 | ||
| 210 | 9x |
function(x) {
|
| 211 | 9x |
need_discrete(x) |
| 212 | ||
| 213 | 9x |
domain <- make_levels(x, levels = domain, ordered = ordered) |
| 214 | 9x |
x <- match(as.character(x), domain) |
| 215 | ||
| 216 | 9x |
if (is.null(symbols)) {
|
| 217 | 4x |
n <- length(domain) |
| 218 | 4x |
if (n > 6) {
|
| 219 | 1x |
warning(tr_("Consider specifying symbols manually: "),
|
| 220 | 1x |
tr_("more than 6 becomes difficult to discriminate."),
|
| 221 | 1x |
call. = FALSE) |
| 222 |
} |
|
| 223 | 4x |
symbols <- c(16, 17, 15, 3, 7, 8)[seq_len(n)] |
| 224 |
} |
|
| 225 | 9x |
symbols[x] |
| 226 |
} |
|
| 227 |
} |
|
| 228 | ||
| 229 |
#' @export |
|
| 230 |
#' @rdname palette_shape |
|
| 231 |
palette_line <- function(types = NULL, domain = NULL, ordered = FALSE, ...) {
|
|
| 232 | ! |
if (is.null(types)) {
|
| 233 | ! |
types <- c("solid", "22", "42", "44", "13", "1343", "73", "2262",
|
| 234 | ! |
"12223242", "F282", "F4448444", "224282F2", "F1") |
| 235 |
} |
|
| 236 | ! |
palette_shape(symbols = types, domain = domain, ordered = ordered, ...) |
| 237 |
} |
|
| 238 | ||
| 239 |
## Size ------------------------------------------------------------------------ |
|
| 240 |
#' Symbol Size Mapping |
|
| 241 |
#' |
|
| 242 |
#' @param range A length-two [`numeric`] vector giving range of possible sizes |
|
| 243 |
#' (greater than 0). |
|
| 244 |
#' @param midpoint A length-one [`numeric`] vector specifying the data mid-point. |
|
| 245 |
#' @param ... Currently not used. |
|
| 246 |
#' @return |
|
| 247 |
#' A palette [`function`] that when called with a single argument |
|
| 248 |
#' (a [`numeric`] vector of continuous values) returns a [`numeric`] vector |
|
| 249 |
#' giving the amount by which plotting text and symbols should be magnified |
|
| 250 |
#' relative to the default. |
|
| 251 |
#' @example inst/examples/ex-palette-continuous.R |
|
| 252 |
#' @family palettes |
|
| 253 |
#' @name palette_size |
|
| 254 |
#' @rdname palette_size |
|
| 255 |
NULL |
|
| 256 | ||
| 257 |
#' @export |
|
| 258 |
#' @rdname palette_size |
|
| 259 |
palette_size_sequential <- function(range = c(1, 6), ...) {
|
|
| 260 | ||
| 261 | 6x |
force(range) |
| 262 | ||
| 263 | 6x |
function(x) {
|
| 264 | 6x |
need_continuous(x) |
| 265 | 5x |
x <- scale_range(x) |
| 266 | 5x |
scale_range(sqrt(x), to = range(range, na.rm = TRUE)) |
| 267 |
} |
|
| 268 |
} |
|
| 269 | ||
| 270 |
#' @export |
|
| 271 |
#' @rdname palette_size |
|
| 272 |
palette_size_diverging <- function(range = c(1, 6), midpoint = 0, ...) {
|
|
| 273 | ||
| 274 | 2x |
force(range) |
| 275 | 2x |
force(midpoint) |
| 276 | ||
| 277 | 2x |
function(x) {
|
| 278 | 2x |
need_continuous(x) |
| 279 | 1x |
x <- scale_midpoint(abs(x), midpoint = midpoint) |
| 280 | 1x |
scale_range(sqrt(x), to = range(range, na.rm = TRUE)) |
| 281 |
} |
|
| 282 |
} |
|
| 283 | ||
| 284 |
# Scales ======================================================================= |
|
| 285 |
#' Rescale Continuous Vector (minimum, maximum) |
|
| 286 |
#' |
|
| 287 |
#' Rescales continuous vector to have specified minimum and maximum. |
|
| 288 |
#' @param x A [`numeric`] vector. |
|
| 289 |
#' @param to A length-two [`numeric`] vector specifying the output range. |
|
| 290 |
#' @param from A length-two [`numeric`] vector specifying the input range. |
|
| 291 |
#' @return A [`numeric`] vector. |
|
| 292 |
#' @family scales |
|
| 293 |
#' @keywords internal |
|
| 294 |
#' @noRd |
|
| 295 |
scale_range <- function(x, to = c(0, 1), from = range(x, finite = TRUE)) {
|
|
| 296 | 1x |
if (is_zero(to) || is_zero(from)) return(ifelse(is.na(x), NA, mean(to))) |
| 297 | 25x |
(x - from[1L]) / diff(from) * diff(to) + to[1L] |
| 298 |
} |
|
| 299 | ||
| 300 |
#' Rescale Continuous Vector (minimum, midpoint, maximum) |
|
| 301 |
#' |
|
| 302 |
#' Rescales continuous vector to have specified minimum, midpoint and maximum. |
|
| 303 |
#' @param x A [`numeric`] vector. |
|
| 304 |
#' @param to A length-two [`numeric`] vector specifying the output range. |
|
| 305 |
#' @param from A length-two [`numeric`] vector specifying the input range. |
|
| 306 |
#' @param midpoint A length-one [`numeric`] vector specifying the mid-point of |
|
| 307 |
#' input range. |
|
| 308 |
#' @return A [`numeric`] vector. |
|
| 309 |
#' @family scales |
|
| 310 |
#' @keywords internal |
|
| 311 |
#' @noRd |
|
| 312 |
scale_midpoint <- function(x, to = c(0, 1), from = range(x, finite = TRUE), |
|
| 313 |
midpoint = 0) {
|
|
| 314 | ! |
if (is_zero(to) || is_zero(from)) return(ifelse(is.na(x), NA, mean(to))) |
| 315 | 4x |
extent <- 2 * max(abs(from - midpoint)) |
| 316 | 4x |
(x - midpoint) / extent * diff(to) + mean(to) |
| 317 |
} |
|
| 318 | ||
| 319 |
# Helpers ====================================================================== |
|
| 320 |
need_continuous <- function(x) {
|
|
| 321 | 22x |
if (!is.numeric(x)) {
|
| 322 | 4x |
stop(tr_("Discrete value supplied to continuous scale."), call. = FALSE)
|
| 323 |
} |
|
| 324 | 18x |
invisible(x) |
| 325 |
} |
|
| 326 | ||
| 327 |
need_discrete <- function(x) {
|
|
| 328 | 24x |
if (is.double(x)) {
|
| 329 | 2x |
warning(tr_("Continuous value supplied to discrete scale."), call. = FALSE)
|
| 330 |
} |
|
| 331 | 24x |
invisible(x) |
| 332 |
} |
|
| 333 | ||
| 334 |
is_zero <- function(x, tolerance = sqrt(.Machine$double.eps)) {
|
|
| 335 | 59x |
diff(range(x)) <= tolerance |
| 336 |
} |
|
| 337 | ||
| 338 |
make_levels <- function(x, levels = NULL, ordered = FALSE) {
|
|
| 339 | 12x |
if (!is.null(levels)) return(make_levels(x = levels, ordered = ordered)) |
| 340 | ||
| 341 | ! |
if (is.null(x)) levels <- NULL |
| 342 | ! |
else if (is.factor(x)) levels <- levels(x) |
| 343 | 4x |
else if (ordered) levels <- unique(x) |
| 344 | 20x |
else levels <- sort(unique(x)) |
| 345 | 24x |
levels |
| 346 |
} |
| 1 |
#' Simulate Color-Blindness |
|
| 2 |
#' |
|
| 3 |
#' @param x A palette [`function`] that when called with a single |
|
| 4 |
#' integer argument (the number of levels) returns a vector of colors |
|
| 5 |
#' (see [color()]). |
|
| 6 |
#' @param mode A [`character`] string giving the colorblind vision |
|
| 7 |
#' to be used. It must be one of "`deuteranopia`", "`protanopia`", |
|
| 8 |
#' "`tritanopia`" or "`achromatopsia`". Any unambiguous substring can be given. |
|
| 9 |
#' @return |
|
| 10 |
#' A palette [`function`] that returns a vector of anomalized |
|
| 11 |
#' colors. All the attributes of the initial palette function are inherited, |
|
| 12 |
#' with a supplementary attribute "`mode`" giving the corresponding |
|
| 13 |
#' color-blind vision. |
|
| 14 |
#' @example inst/examples/ex-change.R |
|
| 15 |
#' @references |
|
| 16 |
#' Brettel, H., Viénot, F. and Mollon, J. D. (1997). Computerized Simulation of |
|
| 17 |
#' Color Appearance for Dichromats. *Journal of the Optical Society of America |
|
| 18 |
#' A*, 14(10), p. 2647-2655. \doi{10.1364/JOSAA.14.002647}.
|
|
| 19 |
#' |
|
| 20 |
#' Tol, P. (2018). *Colour Schemes*. SRON. Technical Note No. |
|
| 21 |
#' SRON/EPS/TN/09-002, issue 3.1. |
|
| 22 |
#' URL: \url{https://sronpersonalpages.nl/~pault/data/colourschemes.pdf}
|
|
| 23 |
#' |
|
| 24 |
#' Viénot, F., Brettel, H. and Mollon, J. D. (1999). Digital Video |
|
| 25 |
#' Colourmaps for Checking the Legibility of Displays by Dichromats. |
|
| 26 |
#' *Color Research & Application*, 24(4), p. 243-52. |
|
| 27 |
#' \doi{10.1002/(SICI)1520-6378(199908)24:4<243::AID-COL5>3.0.CO;2-3}.
|
|
| 28 |
#' @author N. Frerebeau |
|
| 29 |
#' @family diagnostic tools |
|
| 30 |
#' @export |
|
| 31 |
change <- function(x, mode) {
|
|
| 32 | 4x |
fun <- function(n) { anomalize(x(n), mode = mode) }
|
| 33 | 4x |
attributes(fun) <- attributes(x) |
| 34 | 4x |
attr(fun, "mode") <- mode |
| 35 | 4x |
fun |
| 36 |
} |
|
| 37 | ||
| 38 |
#' Anomalize |
|
| 39 |
#' |
|
| 40 |
#' @param x A [`character`] vector of color codes. |
|
| 41 |
#' @param mode A [`character`] string giving the colorblind vision |
|
| 42 |
#' to be used. It must be one of "`deuteranopia`", "`protanopia`", |
|
| 43 |
#' "`tritanopia`" or "`achromatopsia`". Any unambiguous substring can be given. |
|
| 44 |
#' @return A [`character`] vector of color codes. |
|
| 45 |
#' @author N. Frerebeau |
|
| 46 |
#' @keywords internal |
|
| 47 |
#' @noRd |
|
| 48 |
anomalize <- function(x, mode = c("deuteranopia", "protanopia", "tritanopia",
|
|
| 49 |
"achromatopsia")) {
|
|
| 50 |
# Validation |
|
| 51 | 4x |
mode <- match.arg(mode, several.ok = FALSE) |
| 52 | ||
| 53 |
# Convert to RGB color code |
|
| 54 | 4x |
RGB1 <- t(grDevices::col2rgb(x, alpha = FALSE)) |
| 55 | ||
| 56 |
# Dichromat |
|
| 57 | 4x |
S <- switch ( |
| 58 | 4x |
mode, |
| 59 |
# Green-blindness |
|
| 60 | 4x |
deuteranopia = rbind( |
| 61 |
# Red, Green, Blue |
|
| 62 | 4x |
c(1, 0, 0), |
| 63 | 4x |
c(0.9513092, 0, 0.04866992), |
| 64 | 4x |
c(0, 0, 1) |
| 65 |
), |
|
| 66 |
# Red-blindness |
|
| 67 | 4x |
protanopia = rbind( |
| 68 |
# Red, Green, Blue |
|
| 69 | 4x |
c(0, 1.05118294, -0.05116099), |
| 70 | 4x |
c(0, 1, 0), |
| 71 | 4x |
c(0, 0, 1) |
| 72 |
), |
|
| 73 |
# Blue-blindness |
|
| 74 | 4x |
tritanopia = rbind( |
| 75 |
# Red, Green, Blue |
|
| 76 | 4x |
c(1, 0, 0), |
| 77 | 4x |
c(0, 1, 0), |
| 78 | 4x |
c(-0.86744736, 1.86727089, 0) |
| 79 |
), |
|
| 80 |
# Achromatopsia |
|
| 81 | 4x |
achromatopsia = rbind( |
| 82 |
# Red, Green, Blue |
|
| 83 | 4x |
c(0, 0, 1), |
| 84 | 4x |
c(0, 0, 1), |
| 85 | 4x |
c(0, 0, 1) |
| 86 |
) |
|
| 87 |
) |
|
| 88 | ||
| 89 |
# Convert colors from the RGB color space to the LMS color space |
|
| 90 |
# RGB_to_LMS <- .XYZ_to_LMS %*% .sRGB_to_XYZ |
|
| 91 |
# RGB2 <- solve(RGB_to_LMS) %*% S %*% RGB_to_LMS %*% RGB1 |
|
| 92 | ||
| 93 |
# Conversion |
|
| 94 | 4x |
LMS <- RGB2LMS(RGB1) %*% t(S) |
| 95 | 4x |
RGB2 <- LMS2RGB(LMS) |
| 96 | ||
| 97 |
# RGB constraints |
|
| 98 | 4x |
for (i in 1:nrow(RGB2)) {
|
| 99 | 28x |
RGB2[i, ] <- pmin(RGB2[i, ], rep(255, 3)) |
| 100 | 28x |
RGB2[i, ] <- pmax(RGB2[i, ], rep(0, 3)) |
| 101 |
} |
|
| 102 | ||
| 103 |
# Convert to Hex color code |
|
| 104 | 4x |
grDevices::rgb(RGB2, names = names(x), maxColorValue = 255) |
| 105 |
} |
|
| 106 | ||
| 107 |
# Color Conversion |
|
| 108 | ||
| 109 |
#' CMYK to/from RGB Color Conversion |
|
| 110 |
#' |
|
| 111 |
#' @param cyan,magenta,yellow,black,red,blue,green A [`numeric`] vector with |
|
| 112 |
#' values in \eqn{[0, max]}.
|
|
| 113 |
#' @param max A [`numeric`] value giving the maximum of the color values range. |
|
| 114 |
#' @return An integer matrix with three or four columns. |
|
| 115 |
#' @author N. Frerebeau |
|
| 116 |
#' @keywords internal |
|
| 117 |
#' @noRd |
|
| 118 |
NULL |
|
| 119 | ||
| 120 |
CMYK2RGB <- function(cyan, magenta, yellow, black, max = 1) {
|
|
| 121 | 4x |
if (missing(magenta) && missing(yellow) && missing(black)) {
|
| 122 | 1x |
if (is.matrix(cyan) || is.data.frame(cyan)) {
|
| 123 | ! |
if (ncol(cyan) < 4L) stop("At least 4 columns needed.", call. = FALSE)
|
| 124 | 1x |
cyan <- data.matrix(cyan) |
| 125 | 1x |
CMY <- cyan[, -4] |
| 126 | 1x |
black <- cyan[, 4] |
| 127 |
} |
|
| 128 |
} else {
|
|
| 129 | 3x |
CMY <- cbind(cyan, magenta, yellow) |
| 130 |
} |
|
| 131 | 4x |
CMY <- CMY / max |
| 132 | 4x |
K <- black / max |
| 133 | ||
| 134 | 4x |
RGB <- 255 * (1 - CMY) * (1 - K) |
| 135 | 4x |
colnames(RGB) <- c("R", "G", "B")
|
| 136 | 4x |
return(RGB) |
| 137 |
} |
|
| 138 | ||
| 139 |
RGB2CMYB <- function(red, green, blue, max = 255) {
|
|
| 140 | 4x |
if (missing(green) && missing(blue)) {
|
| 141 | 1x |
if (is.matrix(red) || is.data.frame(red)) {
|
| 142 | ! |
if (ncol(red) < 3L) stop("At least 3 columns needed.", call. = FALSE)
|
| 143 | 1x |
RGB <- data.matrix(red) |
| 144 |
} |
|
| 145 |
} else {
|
|
| 146 | 3x |
RGB <- cbind(red, green, blue) |
| 147 |
} |
|
| 148 | 4x |
RGB <- RGB / max |
| 149 | 4x |
K <- 1 - apply(X = RGB, MARGIN = 1, FUN = max) |
| 150 | 4x |
CMY <- (1 - RGB - K) / (1 - K) |
| 151 | 4x |
CMYK <- cbind(CMY, K) |
| 152 | 4x |
CMYK[is.na(CMYK)] <- 0 # Fix zero division |
| 153 | 4x |
colnames(CMYK) <- c("C", "M", "Y", "K")
|
| 154 | 4x |
return(CMYK) |
| 155 |
} |
|
| 156 | ||
| 157 |
#' RGB to/from XYZ Color Conversion |
|
| 158 |
#' |
|
| 159 |
#' @param red,blue,green A [`numeric`] vector with values in \eqn{[0, max]}.
|
|
| 160 |
#' @param x,y,z A [`numeric`] vector of color coordinates. |
|
| 161 |
#' @param max A [`numeric`] value giving the maximum of the color values range. |
|
| 162 |
#' @return A numeric matrix with three columns. |
|
| 163 |
#' @author N. Frerebeau |
|
| 164 |
#' @keywords internal |
|
| 165 |
#' @noRd |
|
| 166 |
NULL |
|
| 167 | ||
| 168 |
gamma_expand <- function(RGB) {
|
|
| 169 | 9x |
u <- RGB > 0.04045 |
| 170 | 9x |
sRGB <- RGB / 12.92 |
| 171 | 9x |
sRGB[u] <- ((200 * RGB[u] + 11) / 211)^(12 / 5) |
| 172 | 9x |
return(sRGB) |
| 173 |
} |
|
| 174 |
gamma_compress <- function(sRGB) {
|
|
| 175 | 8x |
u <- sRGB > 0.0031308 |
| 176 | 8x |
RGB <- sRGB * 12.92 |
| 177 | 8x |
RGB[u] <- (211 * sRGB[u]^(5 / 12) - 11) / 200 |
| 178 | 8x |
return(RGB) |
| 179 |
} |
|
| 180 | ||
| 181 |
XYZ2RGB <- function(x, y, z, max_rgb = 255) {
|
|
| 182 | 4x |
if (missing(y) && missing(z)) {
|
| 183 | 1x |
if (is.matrix(x) || is.data.frame(x)) {
|
| 184 | ! |
if (ncol(x) < 3L) stop("At least 3 columns needed.", call. = FALSE)
|
| 185 | 1x |
XYZ <- data.matrix(x) |
| 186 |
} |
|
| 187 |
} else {
|
|
| 188 | 3x |
XYZ <- cbind(x, y, z) |
| 189 |
} |
|
| 190 | 4x |
sRGB <- XYZ %*% t(.XYZ_to_sRGB) |
| 191 | 4x |
colnames(sRGB) <- c("R", "G", "B")
|
| 192 | ||
| 193 |
# gamma-compressed values |
|
| 194 | 4x |
RGB <- gamma_compress(sRGB) |
| 195 | ||
| 196 | 4x |
return(RGB * max_rgb) |
| 197 |
} |
|
| 198 | ||
| 199 |
RGB2XYZ <- function(red, green, blue, max_rgb = 255) {
|
|
| 200 | 5x |
if (missing(green) && missing(blue)) {
|
| 201 | 2x |
if (is.matrix(red) || is.data.frame(red)) {
|
| 202 | ! |
if (ncol(red) < 3L) stop("At least 3 columns needed.", call. = FALSE)
|
| 203 | 2x |
RGB <- data.matrix(red) |
| 204 |
} |
|
| 205 |
} else {
|
|
| 206 | 3x |
RGB <- cbind(red, green, blue) |
| 207 |
} |
|
| 208 | 5x |
RGB <- RGB / max_rgb |
| 209 | ||
| 210 |
# gamma-expanded values |
|
| 211 | 5x |
sRGB <- gamma_expand(RGB) |
| 212 | ||
| 213 | 5x |
XYZ <- sRGB %*% t(.sRGB_to_XYZ) |
| 214 | 5x |
colnames(XYZ) <- c("X", "Y", "Z")
|
| 215 | 5x |
return(XYZ) |
| 216 |
} |
|
| 217 | ||
| 218 |
#' RGB to/from LMS Lab Color Conversion |
|
| 219 |
#' |
|
| 220 |
#' @param red,blue,green A [`numeric`] vector with values in \eqn{[0, max]}.
|
|
| 221 |
#' @param max A [`numeric`] value giving the maximum of the color values range. |
|
| 222 |
#' @return A numeric matrix with three rows. |
|
| 223 |
#' @author N. Frerebeau |
|
| 224 |
#' @keywords internal |
|
| 225 |
#' @noRd |
|
| 226 |
NULL |
|
| 227 | ||
| 228 |
RGB2LMS <- function(red, green, blue, max = 255) {
|
|
| 229 | 4x |
if (missing(green) && missing(blue)) {
|
| 230 | 4x |
if (is.matrix(red) || is.data.frame(red)) {
|
| 231 | ! |
if (ncol(red) < 3L) stop("At least 3 columns needed.", call. = FALSE)
|
| 232 | 4x |
RGB <- data.matrix(red) |
| 233 |
} |
|
| 234 |
} else {
|
|
| 235 | ! |
RGB <- cbind(red, green, blue) |
| 236 |
} |
|
| 237 | 4x |
RGB <- RGB / max |
| 238 | ||
| 239 |
# gamma-expanded values |
|
| 240 | 4x |
sRGB <- gamma_expand(RGB) |
| 241 | ||
| 242 | 4x |
LMS <- sRGB %*% t(.XYZ_to_LMS %*% .sRGB_to_XYZ) |
| 243 | 4x |
colnames(LMS) <- c("L", "M", "S")
|
| 244 | 4x |
return(LMS) |
| 245 |
} |
|
| 246 | ||
| 247 |
LMS2RGB <- function(long, medium, short, max = 255) {
|
|
| 248 | 4x |
if (missing(medium) && missing(short)) {
|
| 249 | 4x |
if (is.matrix(long) || is.data.frame(long)) {
|
| 250 | ! |
if (ncol(long) < 3L) stop("At least 3 columns needed.", call. = FALSE)
|
| 251 | 4x |
LMS <- data.matrix(long) |
| 252 |
} |
|
| 253 |
} else {
|
|
| 254 | ! |
LMS <- cbind(long, medium, short) |
| 255 |
} |
|
| 256 | ||
| 257 | 4x |
sRGB <- LMS %*% t(solve(.XYZ_to_LMS %*% .sRGB_to_XYZ)) |
| 258 | 4x |
colnames(sRGB) <- c("R", "G", "B")
|
| 259 | ||
| 260 |
# gamma-compressed values |
|
| 261 | 4x |
RGB <- gamma_compress(sRGB) |
| 262 | ||
| 263 | 4x |
return(RGB * max) |
| 264 |
} |
|
| 265 | ||
| 266 |
#' XYZ to CIE Lab Color Conversion |
|
| 267 |
#' |
|
| 268 |
#' @param x,y,z A [`numeric`] vector of color coordinates. |
|
| 269 |
#' @param white A length-three [`numeric`] vector giving a reference white |
|
| 270 |
#' coordinates (default to D65). |
|
| 271 |
#' @return A numeric matrix with three columns. |
|
| 272 |
#' @author N. Frerebeau |
|
| 273 |
#' @keywords internal |
|
| 274 |
#' @noRd |
|
| 275 |
NULL |
|
| 276 | ||
| 277 |
XYZ2Lab <- function(x, y, z, white = c(x = 0.95047, y = 1.00000, z = 1.08883)) {
|
|
| 278 | 1x |
if (missing(y) && missing(z)) {
|
| 279 | 1x |
if (is.matrix(x) || is.data.frame(x)) {
|
| 280 | ! |
if (ncol(x) < 3L) stop("At least 3 columns needed.", call. = FALSE)
|
| 281 | 1x |
XYZ <- data.matrix(x) |
| 282 | 1x |
x <- XYZ[, 1] |
| 283 | 1x |
y <- XYZ[, 2] |
| 284 | 1x |
z <- XYZ[, 3] |
| 285 |
} |
|
| 286 |
} |
|
| 287 | ||
| 288 |
# Actual CIE standards |
|
| 289 | 1x |
f <- function(a, e = 0.008856, k = 903.3) {
|
| 290 | 5x |
a_e <- a <= e |
| 291 | 5x |
b <- a^(1/3) |
| 292 | 5x |
b[a_e] <- (k * a[a_e] + 16) / 116 |
| 293 | 5x |
b |
| 294 |
} |
|
| 295 | ||
| 296 | 1x |
x <- x / white[[1L]] |
| 297 | 1x |
y <- y / white[[2L]] |
| 298 | 1x |
z <- z / white[[3L]] |
| 299 | ||
| 300 | 1x |
Lab <- cbind( |
| 301 | 1x |
L = 116 * f(y) - 16, |
| 302 | 1x |
a = 500 * (f(x) - f(y)), |
| 303 | 1x |
b = 200 * (f(y) - f(z)) |
| 304 |
) |
|
| 305 | 1x |
return(Lab) |
| 306 |
} |
| 1 |
# Paul Tol's color schemes |
|
| 2 |
#' @include color.R |
|
| 3 |
NULL |
|
| 4 | ||
| 5 |
# Discrete ===================================================================== |
|
| 6 |
## Bright ---------------------------------------------------------------------- |
|
| 7 |
#' Paul Tol's *bright* Discrete Color Scheme |
|
| 8 |
#' |
|
| 9 |
#' @param ... Arguments passed to [ggplot2::discrete_scale()]. |
|
| 10 |
#' @param reverse A [`logical`] scalar. Should the resulting |
|
| 11 |
#' vector of colors be reversed? |
|
| 12 |
#' @param aesthetics A [`character`] string or vector of character |
|
| 13 |
#' strings listing the name(s) of the aesthetic(s) that this scale works with. |
|
| 14 |
#' @inheritSection tol Qualitative Color Schemes |
|
| 15 |
#' @return A [discrete][ggplot2::discrete_scale] scale. |
|
| 16 |
#' @references |
|
| 17 |
#' Tol, P. (2021). *Colour Schemes*. SRON. Technical Note No. |
|
| 18 |
#' SRON/EPS/TN/09-002, issue 3.2. |
|
| 19 |
#' URL: \url{https://sronpersonalpages.nl/~pault/data/colourschemes.pdf}
|
|
| 20 |
#' @example inst/examples/ex-tol-discrete.R |
|
| 21 |
#' @author N. Frerebeau |
|
| 22 |
#' @family qualitative color schemes |
|
| 23 |
#' @family Paul Tol's color schemes |
|
| 24 |
#' @name scale_tol_bright |
|
| 25 |
#' @rdname scale_tol_bright |
|
| 26 |
NULL |
|
| 27 | ||
| 28 |
#' @export |
|
| 29 |
#' @rdname scale_tol_bright |
|
| 30 |
scale_colour_bright <- function(..., reverse = FALSE, aesthetics = "colour") {
|
|
| 31 | 5x |
scale_discrete(aesthetics, "bright", reverse = reverse, ...) |
| 32 |
} |
|
| 33 | ||
| 34 |
#' @export |
|
| 35 |
#' @rdname scale_tol_bright |
|
| 36 |
scale_color_bright <- scale_colour_bright |
|
| 37 | ||
| 38 |
#' @export |
|
| 39 |
#' @rdname scale_tol_bright |
|
| 40 |
scale_fill_bright <- function(..., reverse = FALSE, aesthetics = "fill") {
|
|
| 41 | 3x |
scale_discrete(aesthetics, "bright", reverse = reverse, ...) |
| 42 |
} |
|
| 43 | ||
| 44 |
#' @export |
|
| 45 |
#' @rdname scale_tol_bright |
|
| 46 |
scale_edge_colour_bright <- function(..., reverse = FALSE, |
|
| 47 |
aesthetics = "edge_colour") {
|
|
| 48 | 5x |
scale_discrete(aesthetics, "bright", reverse = reverse, ...) |
| 49 |
} |
|
| 50 | ||
| 51 |
#' @export |
|
| 52 |
#' @rdname scale_tol_bright |
|
| 53 |
scale_edge_color_bright <- scale_edge_colour_bright |
|
| 54 | ||
| 55 |
#' @export |
|
| 56 |
#' @rdname scale_tol_bright |
|
| 57 |
scale_edge_fill_bright <- function(..., reverse = FALSE, |
|
| 58 |
aesthetics = "edge_fill") {
|
|
| 59 | 3x |
scale_discrete(aesthetics, "bright", reverse = reverse, ...) |
| 60 |
} |
|
| 61 | ||
| 62 |
## High contrast --------------------------------------------------------------- |
|
| 63 |
#' Paul Tol's *high contrast* Discrete Color Scheme |
|
| 64 |
#' |
|
| 65 |
#' @inheritParams scale_tol_bright |
|
| 66 |
#' @inheritSection tol Qualitative Color Schemes |
|
| 67 |
#' @return A [discrete][ggplot2::discrete_scale] scale. |
|
| 68 |
#' @references |
|
| 69 |
#' Tol, P. (2021). *Colour Schemes*. SRON. Technical Note No. |
|
| 70 |
#' SRON/EPS/TN/09-002, issue 3.2. |
|
| 71 |
#' URL: \url{https://sronpersonalpages.nl/~pault/data/colourschemes.pdf}
|
|
| 72 |
#' @example inst/examples/ex-tol-discrete.R |
|
| 73 |
#' @author N. Frerebeau |
|
| 74 |
#' @family qualitative color schemes |
|
| 75 |
#' @family Paul Tol's color schemes |
|
| 76 |
#' @name scale_tol_highcontrast |
|
| 77 |
#' @rdname scale_tol_highcontrast |
|
| 78 |
NULL |
|
| 79 | ||
| 80 |
#' @export |
|
| 81 |
#' @rdname scale_tol_highcontrast |
|
| 82 |
scale_colour_highcontrast <- function(..., reverse = FALSE, |
|
| 83 |
aesthetics = "colour") {
|
|
| 84 | 5x |
scale_discrete(aesthetics, "highcontrast", reverse = reverse, ...) |
| 85 |
} |
|
| 86 | ||
| 87 |
#' @export |
|
| 88 |
#' @rdname scale_tol_highcontrast |
|
| 89 |
scale_color_highcontrast <- scale_colour_highcontrast |
|
| 90 | ||
| 91 |
#' @export |
|
| 92 |
#' @rdname scale_tol_highcontrast |
|
| 93 |
scale_fill_highcontrast <- function(..., reverse = FALSE, |
|
| 94 |
aesthetics = "fill") {
|
|
| 95 | 3x |
scale_discrete(aesthetics, "highcontrast", reverse = reverse, ...) |
| 96 |
} |
|
| 97 | ||
| 98 |
#' @export |
|
| 99 |
#' @rdname scale_tol_highcontrast |
|
| 100 |
scale_edge_colour_highcontrast <- function(..., reverse = FALSE, |
|
| 101 |
aesthetics = "edge_colour") {
|
|
| 102 | 5x |
scale_discrete(aesthetics, "highcontrast", reverse = reverse, ...) |
| 103 |
} |
|
| 104 | ||
| 105 |
#' @export |
|
| 106 |
#' @rdname scale_tol_highcontrast |
|
| 107 |
scale_edge_color_highcontrast <- scale_edge_colour_highcontrast |
|
| 108 | ||
| 109 |
#' @export |
|
| 110 |
#' @rdname scale_tol_highcontrast |
|
| 111 |
scale_edge_fill_highcontrast <- function(..., reverse = FALSE, |
|
| 112 |
aesthetics = "edge_fill") {
|
|
| 113 | 3x |
scale_discrete(aesthetics, "highcontrast", reverse = reverse, ...) |
| 114 |
} |
|
| 115 | ||
| 116 |
## Vibrant --------------------------------------------------------------------- |
|
| 117 |
#' Paul Tol's *vibrant* Discrete Color Scheme |
|
| 118 |
#' |
|
| 119 |
#' @inheritParams scale_tol_bright |
|
| 120 |
#' @inheritSection tol Qualitative Color Schemes |
|
| 121 |
#' @return A [discrete][ggplot2::discrete_scale] scale. |
|
| 122 |
#' @references |
|
| 123 |
#' Tol, P. (2021). *Colour Schemes*. SRON. Technical Note No. |
|
| 124 |
#' SRON/EPS/TN/09-002, issue 3.2. |
|
| 125 |
#' URL: \url{https://sronpersonalpages.nl/~pault/data/colourschemes.pdf}
|
|
| 126 |
#' @example inst/examples/ex-tol-discrete.R |
|
| 127 |
#' @author N. Frerebeau |
|
| 128 |
#' @family qualitative color schemes |
|
| 129 |
#' @family Paul Tol's color schemes |
|
| 130 |
#' @name scale_tol_vibrant |
|
| 131 |
#' @rdname scale_tol_vibrant |
|
| 132 |
NULL |
|
| 133 | ||
| 134 |
#' @export |
|
| 135 |
#' @rdname scale_tol_vibrant |
|
| 136 |
scale_colour_vibrant <- function(..., reverse = FALSE, aesthetics = "colour") {
|
|
| 137 | 5x |
scale_discrete(aesthetics, "vibrant", reverse = reverse, ...) |
| 138 |
} |
|
| 139 | ||
| 140 |
#' @export |
|
| 141 |
#' @rdname scale_tol_vibrant |
|
| 142 |
scale_color_vibrant <- scale_colour_vibrant |
|
| 143 | ||
| 144 |
#' @export |
|
| 145 |
#' @rdname scale_tol_vibrant |
|
| 146 |
scale_fill_vibrant <- function(..., reverse = FALSE, aesthetics = "fill") {
|
|
| 147 | 3x |
scale_discrete(aesthetics, "vibrant", reverse = reverse, ...) |
| 148 |
} |
|
| 149 | ||
| 150 |
#' @export |
|
| 151 |
#' @rdname scale_tol_vibrant |
|
| 152 |
scale_edge_colour_vibrant <- function(..., reverse = FALSE, |
|
| 153 |
aesthetics = "edge_colour") {
|
|
| 154 | 5x |
scale_discrete(aesthetics, "vibrant", reverse = reverse, ...) |
| 155 |
} |
|
| 156 | ||
| 157 |
#' @export |
|
| 158 |
#' @rdname scale_tol_vibrant |
|
| 159 |
scale_edge_color_vibrant <- scale_edge_colour_vibrant |
|
| 160 | ||
| 161 |
#' @export |
|
| 162 |
#' @rdname scale_tol_vibrant |
|
| 163 |
scale_edge_fill_vibrant <- function(..., reverse = FALSE, |
|
| 164 |
aesthetics = "edge_fill") {
|
|
| 165 | 3x |
scale_discrete(aesthetics, "vibrant", reverse = reverse, ...) |
| 166 |
} |
|
| 167 | ||
| 168 |
## Muted ----------------------------------------------------------------------- |
|
| 169 |
#' Paul Tol's *muted* Discrete Color Scheme |
|
| 170 |
#' |
|
| 171 |
#' @inheritParams scale_tol_bright |
|
| 172 |
#' @inheritSection tol Qualitative Color Schemes |
|
| 173 |
#' @return A [discrete][ggplot2::discrete_scale] scale. |
|
| 174 |
#' @references |
|
| 175 |
#' Tol, P. (2021). *Colour Schemes*. SRON. Technical Note No. |
|
| 176 |
#' SRON/EPS/TN/09-002, issue 3.2. |
|
| 177 |
#' URL: \url{https://sronpersonalpages.nl/~pault/data/colourschemes.pdf}
|
|
| 178 |
#' @example inst/examples/ex-tol-discrete.R |
|
| 179 |
#' @author N. Frerebeau |
|
| 180 |
#' @family qualitative color schemes |
|
| 181 |
#' @family Paul Tol's color schemes |
|
| 182 |
#' @name scale_tol_muted |
|
| 183 |
#' @rdname scale_tol_muted |
|
| 184 |
NULL |
|
| 185 | ||
| 186 |
#' @export |
|
| 187 |
#' @rdname scale_tol_muted |
|
| 188 |
scale_colour_muted <- function(..., reverse = FALSE, aesthetics = "colour") {
|
|
| 189 | 8x |
scale_discrete(aesthetics, "muted", reverse = reverse, ...) |
| 190 |
} |
|
| 191 | ||
| 192 |
#' @export |
|
| 193 |
#' @rdname scale_tol_muted |
|
| 194 |
scale_color_muted <- scale_colour_muted |
|
| 195 | ||
| 196 |
#' @export |
|
| 197 |
#' @rdname scale_tol_muted |
|
| 198 |
scale_fill_muted <- function(..., reverse = FALSE, aesthetics = "fill") {
|
|
| 199 | 4x |
scale_discrete(aesthetics, "muted", reverse = reverse, ...) |
| 200 |
} |
|
| 201 | ||
| 202 |
#' @export |
|
| 203 |
#' @rdname scale_tol_muted |
|
| 204 |
scale_edge_colour_muted <- function(..., reverse = FALSE, |
|
| 205 |
aesthetics = "edge_colour") {
|
|
| 206 | 8x |
scale_discrete(aesthetics, "muted", reverse = reverse, ...) |
| 207 |
} |
|
| 208 | ||
| 209 |
#' @export |
|
| 210 |
#' @rdname scale_tol_muted |
|
| 211 |
scale_edge_color_muted <- scale_edge_colour_muted |
|
| 212 | ||
| 213 |
#' @export |
|
| 214 |
#' @rdname scale_tol_muted |
|
| 215 |
scale_edge_fill_muted <- function(..., reverse = FALSE, |
|
| 216 |
aesthetics = "edge_fill") {
|
|
| 217 | 4x |
scale_discrete(aesthetics, "muted", reverse = reverse, ...) |
| 218 |
} |
|
| 219 | ||
| 220 |
## Medium contrast ------------------------------------------------------------- |
|
| 221 |
#' Paul Tol's *medium contrast* Discrete Color Scheme |
|
| 222 |
#' |
|
| 223 |
#' @inheritParams scale_tol_bright |
|
| 224 |
#' @inheritSection tol Qualitative Color Schemes |
|
| 225 |
#' @return A [discrete][ggplot2::discrete_scale] scale. |
|
| 226 |
#' @references |
|
| 227 |
#' Tol, P. (2021). *Colour Schemes*. SRON. Technical Note No. |
|
| 228 |
#' SRON/EPS/TN/09-002, issue 3.2. |
|
| 229 |
#' URL: \url{https://sronpersonalpages.nl/~pault/data/colourschemes.pdf}
|
|
| 230 |
#' @example inst/examples/ex-tol-discrete.R |
|
| 231 |
#' @author N. Frerebeau |
|
| 232 |
#' @family qualitative color schemes |
|
| 233 |
#' @family Paul Tol's color schemes |
|
| 234 |
#' @name scale_tol_mediumcontrast |
|
| 235 |
#' @rdname scale_tol_mediumcontrast |
|
| 236 |
NULL |
|
| 237 | ||
| 238 |
#' @export |
|
| 239 |
#' @rdname scale_tol_mediumcontrast |
|
| 240 |
scale_colour_mediumcontrast <- function(..., reverse = FALSE, |
|
| 241 |
aesthetics = "colour") {
|
|
| 242 | 5x |
scale_discrete(aesthetics, "mediumcontrast", reverse = reverse, ...) |
| 243 |
} |
|
| 244 | ||
| 245 |
#' @export |
|
| 246 |
#' @rdname scale_tol_mediumcontrast |
|
| 247 |
scale_color_mediumcontrast <- scale_colour_mediumcontrast |
|
| 248 | ||
| 249 |
#' @export |
|
| 250 |
#' @rdname scale_tol_mediumcontrast |
|
| 251 |
scale_fill_mediumcontrast <- function(..., reverse = FALSE, |
|
| 252 |
aesthetics = "fill") {
|
|
| 253 | 3x |
scale_discrete(aesthetics, "mediumcontrast", reverse = reverse, ...) |
| 254 |
} |
|
| 255 | ||
| 256 |
#' @export |
|
| 257 |
#' @rdname scale_tol_mediumcontrast |
|
| 258 |
scale_edge_colour_mediumcontrast <- function(..., reverse = FALSE, |
|
| 259 |
aesthetics = "edge_colour") {
|
|
| 260 | 5x |
scale_discrete(aesthetics, "mediumcontrast", reverse = reverse, ...) |
| 261 |
} |
|
| 262 | ||
| 263 |
#' @export |
|
| 264 |
#' @rdname scale_tol_mediumcontrast |
|
| 265 |
scale_edge_color_mediumcontrast <- scale_edge_colour_mediumcontrast |
|
| 266 | ||
| 267 |
#' @export |
|
| 268 |
#' @rdname scale_tol_mediumcontrast |
|
| 269 |
scale_edge_fill_mediumcontrast <- function(..., reverse = FALSE, |
|
| 270 |
aesthetics = "edge_fill") {
|
|
| 271 | 3x |
scale_discrete(aesthetics, "mediumcontrast", reverse = reverse, ...) |
| 272 |
} |
|
| 273 | ||
| 274 |
## Pale ------------------------------------------------------------------------ |
|
| 275 |
#' Paul Tol's *pale* Discrete Color Scheme |
|
| 276 |
#' |
|
| 277 |
#' @inheritParams scale_tol_bright |
|
| 278 |
#' @inheritSection tol Qualitative Color Schemes |
|
| 279 |
#' @return A [discrete][ggplot2::discrete_scale] scale. |
|
| 280 |
#' @references |
|
| 281 |
#' Tol, P. (2021). *Colour Schemes*. SRON. Technical Note No. |
|
| 282 |
#' SRON/EPS/TN/09-002, issue 3.2. |
|
| 283 |
#' URL: \url{https://sronpersonalpages.nl/~pault/data/colourschemes.pdf}
|
|
| 284 |
#' @example inst/examples/ex-tol-discrete.R |
|
| 285 |
#' @author N. Frerebeau |
|
| 286 |
#' @family qualitative color schemes |
|
| 287 |
#' @family Paul Tol's color schemes |
|
| 288 |
#' @name scale_tol_pale |
|
| 289 |
#' @rdname scale_tol_pale |
|
| 290 |
NULL |
|
| 291 | ||
| 292 |
#' @export |
|
| 293 |
#' @rdname scale_tol_pale |
|
| 294 |
scale_colour_pale <- function(..., reverse = FALSE, aesthetics = "colour") {
|
|
| 295 | 5x |
scale_discrete(aesthetics, "pale", reverse = reverse, ...) |
| 296 |
} |
|
| 297 | ||
| 298 |
#' @export |
|
| 299 |
#' @rdname scale_tol_pale |
|
| 300 |
scale_color_pale <- scale_colour_pale |
|
| 301 | ||
| 302 |
#' @export |
|
| 303 |
#' @rdname scale_tol_pale |
|
| 304 |
scale_fill_pale <- function(..., reverse = FALSE, aesthetics = "fill") {
|
|
| 305 | 3x |
scale_discrete(aesthetics, "pale", reverse = reverse, ...) |
| 306 |
} |
|
| 307 | ||
| 308 |
#' @export |
|
| 309 |
#' @rdname scale_tol_pale |
|
| 310 |
scale_edge_colour_pale <- function(..., reverse = FALSE, |
|
| 311 |
aesthetics = "edge_colour") {
|
|
| 312 | 5x |
scale_discrete(aesthetics, "pale", reverse = reverse, ...) |
| 313 |
} |
|
| 314 | ||
| 315 |
#' @export |
|
| 316 |
#' @rdname scale_tol_pale |
|
| 317 |
scale_edge_color_pale <- scale_edge_colour_pale |
|
| 318 | ||
| 319 |
#' @export |
|
| 320 |
#' @rdname scale_tol_pale |
|
| 321 |
scale_edge_fill_pale <- function(..., reverse = FALSE, |
|
| 322 |
aesthetics = "edge_fill") {
|
|
| 323 | 3x |
scale_discrete(aesthetics, "pale", reverse = reverse, ...) |
| 324 |
} |
|
| 325 | ||
| 326 |
## Dark ------------------------------------------------------------------------ |
|
| 327 |
#' Paul Tol's *dark* Discrete Color Scheme |
|
| 328 |
#' |
|
| 329 |
#' @inheritParams scale_tol_bright |
|
| 330 |
#' @inheritSection tol Qualitative Color Schemes |
|
| 331 |
#' @return A [discrete][ggplot2::discrete_scale] scale. |
|
| 332 |
#' @references |
|
| 333 |
#' Tol, P. (2021). *Colour Schemes*. SRON. Technical Note No. |
|
| 334 |
#' SRON/EPS/TN/09-002, issue 3.2. |
|
| 335 |
#' URL: \url{https://sronpersonalpages.nl/~pault/data/colourschemes.pdf}
|
|
| 336 |
#' @example inst/examples/ex-tol-discrete.R |
|
| 337 |
#' @author N. Frerebeau |
|
| 338 |
#' @family qualitative color schemes |
|
| 339 |
#' @family Paul Tol's color schemes |
|
| 340 |
#' @name scale_tol_dark |
|
| 341 |
#' @rdname scale_tol_dark |
|
| 342 |
NULL |
|
| 343 | ||
| 344 |
#' @export |
|
| 345 |
#' @rdname scale_tol_dark |
|
| 346 |
scale_colour_dark <- function(..., reverse = FALSE, aesthetics = "colour") {
|
|
| 347 | 5x |
scale_discrete(aesthetics, "dark", reverse = reverse, ...) |
| 348 |
} |
|
| 349 | ||
| 350 |
#' @export |
|
| 351 |
#' @rdname scale_tol_dark |
|
| 352 |
scale_color_dark <- scale_colour_dark |
|
| 353 | ||
| 354 |
#' @export |
|
| 355 |
#' @rdname scale_tol_dark |
|
| 356 |
scale_fill_dark <- function(..., reverse = FALSE, aesthetics = "fill") {
|
|
| 357 | 3x |
scale_discrete(aesthetics, "dark", reverse = reverse, ...) |
| 358 |
} |
|
| 359 | ||
| 360 |
#' @export |
|
| 361 |
#' @rdname scale_tol_dark |
|
| 362 |
scale_edge_colour_dark <- function(..., reverse = FALSE, |
|
| 363 |
aesthetics = "edge_colour") {
|
|
| 364 | 5x |
scale_discrete(aesthetics, "dark", reverse = reverse, ...) |
| 365 |
} |
|
| 366 | ||
| 367 |
#' @export |
|
| 368 |
#' @rdname scale_tol_dark |
|
| 369 |
scale_edge_color_dark <- scale_edge_colour_dark |
|
| 370 | ||
| 371 |
#' @export |
|
| 372 |
#' @rdname scale_tol_dark |
|
| 373 |
scale_edge_fill_dark <- function(..., reverse = FALSE, |
|
| 374 |
aesthetics = "edge_fill") {
|
|
| 375 | 3x |
scale_discrete(aesthetics, "dark", reverse = reverse, ...) |
| 376 |
} |
|
| 377 | ||
| 378 |
## Light ----------------------------------------------------------------------- |
|
| 379 |
#' Paul Tol's *light* Discrete Color Scheme |
|
| 380 |
#' |
|
| 381 |
#' @inheritParams scale_tol_bright |
|
| 382 |
#' @inheritSection tol Qualitative Color Schemes |
|
| 383 |
#' @return A [discrete][ggplot2::discrete_scale] scale. |
|
| 384 |
#' @references |
|
| 385 |
#' Tol, P. (2021). *Colour Schemes*. SRON. Technical Note No. |
|
| 386 |
#' SRON/EPS/TN/09-002, issue 3.2. |
|
| 387 |
#' URL: \url{https://sronpersonalpages.nl/~pault/data/colourschemes.pdf}
|
|
| 388 |
#' @example inst/examples/ex-tol-discrete.R |
|
| 389 |
#' @author N. Frerebeau |
|
| 390 |
#' @family qualitative color schemes |
|
| 391 |
#' @family Paul Tol's color schemes |
|
| 392 |
#' @name scale_tol_light |
|
| 393 |
#' @rdname scale_tol_light |
|
| 394 |
NULL |
|
| 395 | ||
| 396 |
#' @export |
|
| 397 |
#' @rdname scale_tol_light |
|
| 398 |
scale_colour_light <- function(..., reverse = FALSE, aesthetics = "colour") {
|
|
| 399 | 5x |
scale_discrete(aesthetics, "light", reverse = reverse, ...) |
| 400 |
} |
|
| 401 | ||
| 402 |
#' @export |
|
| 403 |
#' @rdname scale_tol_light |
|
| 404 |
scale_color_light <- scale_colour_light |
|
| 405 | ||
| 406 |
#' @export |
|
| 407 |
#' @rdname scale_tol_light |
|
| 408 |
scale_fill_light <- function(..., reverse = FALSE, aesthetics = "fill") {
|
|
| 409 | 3x |
scale_discrete(aesthetics, "light", reverse = reverse, ...) |
| 410 |
} |
|
| 411 | ||
| 412 |
#' @export |
|
| 413 |
#' @rdname scale_tol_light |
|
| 414 |
scale_edge_colour_light <- function(..., reverse = FALSE, |
|
| 415 |
aesthetics = "edge_colour") {
|
|
| 416 | 5x |
scale_discrete(aesthetics, "light", reverse = reverse, ...) |
| 417 |
} |
|
| 418 | ||
| 419 |
#' @export |
|
| 420 |
#' @rdname scale_tol_light |
|
| 421 |
scale_edge_color_light <- scale_edge_colour_light |
|
| 422 | ||
| 423 |
#' @export |
|
| 424 |
#' @rdname scale_tol_light |
|
| 425 |
scale_edge_fill_light <- function(..., reverse = FALSE, |
|
| 426 |
aesthetics = "edge_fill") {
|
|
| 427 | 3x |
scale_discrete(aesthetics, "light", reverse = reverse, ...) |
| 428 |
} |
|
| 429 | ||
| 430 |
## Discrete Rainbow ------------------------------------------------------------ |
|
| 431 |
#' Paul Tol's *discrete rainbow* Sequential Color Scheme |
|
| 432 |
#' |
|
| 433 |
#' @inheritParams scale_tol_bright |
|
| 434 |
#' @inheritSection tol Sequential Color Schemes |
|
| 435 |
#' @inheritSection tol Rainbow Color Scheme |
|
| 436 |
#' @return A [discrete][ggplot2::discrete_scale] scale. |
|
| 437 |
#' @references |
|
| 438 |
#' Tol, P. (2018). *Colour Schemes*. SRON. Technical Note No. |
|
| 439 |
#' SRON/EPS/TN/09-002, issue 3.1. |
|
| 440 |
#' URL: \url{https://sronpersonalpages.nl/~pault/data/colourschemes.pdf}
|
|
| 441 |
#' @example inst/examples/ex-tol-discrete.R |
|
| 442 |
#' @author N. Frerebeau |
|
| 443 |
#' @family qualitative color schemes |
|
| 444 |
#' @family Paul Tol's color schemes |
|
| 445 |
#' @name scale_tol_discreterainbow |
|
| 446 |
#' @rdname scale_tol_discreterainbow |
|
| 447 |
NULL |
|
| 448 | ||
| 449 |
#' @export |
|
| 450 |
#' @rdname scale_tol_discreterainbow |
|
| 451 |
scale_colour_discreterainbow <- function(..., reverse = FALSE, |
|
| 452 |
aesthetics = "colour") {
|
|
| 453 | 6x |
scale_discrete(aesthetics, "discreterainbow", reverse = reverse, ...) |
| 454 |
} |
|
| 455 | ||
| 456 |
#' @export |
|
| 457 |
#' @rdname scale_tol_discreterainbow |
|
| 458 |
scale_color_discreterainbow <- scale_colour_discreterainbow |
|
| 459 | ||
| 460 |
#' @export |
|
| 461 |
#' @rdname scale_tol_discreterainbow |
|
| 462 |
scale_fill_discreterainbow <- function(..., reverse = FALSE, |
|
| 463 |
aesthetics = "fill") {
|
|
| 464 | 3x |
scale_discrete(aesthetics, "discreterainbow", reverse = reverse, ...) |
| 465 |
} |
|
| 466 | ||
| 467 |
#' @export |
|
| 468 |
#' @rdname scale_tol_discreterainbow |
|
| 469 |
scale_edge_colour_discreterainbow <- function(..., reverse = FALSE, |
|
| 470 |
aesthetics = "edge_colour") {
|
|
| 471 | 6x |
scale_discrete(aesthetics, "discreterainbow", reverse = reverse, ...) |
| 472 |
} |
|
| 473 | ||
| 474 |
#' @export |
|
| 475 |
#' @rdname scale_tol_discreterainbow |
|
| 476 |
scale_edge_color_discreterainbow <- scale_edge_colour_discreterainbow |
|
| 477 | ||
| 478 |
#' @export |
|
| 479 |
#' @rdname scale_tol_discreterainbow |
|
| 480 |
scale_edge_fill_discreterainbow <- function(..., reverse = FALSE, |
|
| 481 |
aesthetics = "edge_fill") {
|
|
| 482 | 3x |
scale_discrete(aesthetics, "discreterainbow", reverse = reverse, ...) |
| 483 |
} |
|
| 484 | ||
| 485 |
# Diverging ==================================================================== |
|
| 486 |
## Sunset ---------------------------------------------------------------------- |
|
| 487 |
#' Paul Tol's *sunset* Diverging Color Scheme |
|
| 488 |
#' |
|
| 489 |
#' @param ... Arguments passed to [ggplot2::continuous_scale()]. |
|
| 490 |
#' @param reverse A [`logical`] scalar. Should the resulting |
|
| 491 |
#' vector of colors be reversed? |
|
| 492 |
#' @param range A length-two [`numeric`] vector specifying the |
|
| 493 |
#' fraction of the scheme's color domain to keep. |
|
| 494 |
#' @param midpoint A length-one [`numeric`] vector giving the midpoint |
|
| 495 |
#' (in data value) of the diverging scale. Defaults to `0`. |
|
| 496 |
#' @param discrete A [`logical`] scalar: should the color scheme be |
|
| 497 |
#' used as a discrete scale? If `TRUE`, it is a departure from Paul Tol's |
|
| 498 |
#' recommendations and likely a very poor use of color. |
|
| 499 |
#' @param aesthetics A [`character`] string or vector of character |
|
| 500 |
#' strings listing the name(s) of the aesthetic(s) that this scale works with. |
|
| 501 |
#' @inheritSection tol Diverging Color Schemes |
|
| 502 |
#' @return A [continuous][ggplot2::continuous_scale] scale. |
|
| 503 |
#' @references |
|
| 504 |
#' Tol, P. (2018). *Colour Schemes*. SRON. Technical Note No. |
|
| 505 |
#' SRON/EPS/TN/09-002, issue 3.1. |
|
| 506 |
#' URL: \url{https://sronpersonalpages.nl/~pault/data/colourschemes.pdf}
|
|
| 507 |
#' @example inst/examples/ex-tol-diverging.R |
|
| 508 |
#' @author N. Frerebeau |
|
| 509 |
#' @family diverging color schemes |
|
| 510 |
#' @family Paul Tol's color schemes |
|
| 511 |
#' @name scale_tol_sunset |
|
| 512 |
#' @rdname scale_tol_sunset |
|
| 513 |
NULL |
|
| 514 | ||
| 515 |
#' @export |
|
| 516 |
#' @rdname scale_tol_sunset |
|
| 517 |
scale_colour_sunset <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 518 |
midpoint = 0, discrete = FALSE, |
|
| 519 |
aesthetics = "colour") {
|
|
| 520 | 7x |
if (discrete) {
|
| 521 | ! |
scale_discrete(aesthetics, "sunset", reverse = reverse, ...) |
| 522 |
} else {
|
|
| 523 | 7x |
scale_continuous(aesthetics, "sunset", reverse = reverse, range = range, |
| 524 | 7x |
midpoint = midpoint, ...) |
| 525 |
} |
|
| 526 |
} |
|
| 527 | ||
| 528 |
#' @export |
|
| 529 |
#' @rdname scale_tol_sunset |
|
| 530 |
scale_color_sunset <- scale_colour_sunset |
|
| 531 | ||
| 532 |
#' @export |
|
| 533 |
#' @rdname scale_tol_sunset |
|
| 534 |
scale_fill_sunset <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 535 |
midpoint = 0, discrete = FALSE, |
|
| 536 |
aesthetics = "fill") {
|
|
| 537 | 5x |
if (discrete) {
|
| 538 | ! |
scale_discrete(aesthetics, "sunset", reverse = reverse, ...) |
| 539 |
} else {
|
|
| 540 | 5x |
scale_continuous(aesthetics, "sunset", reverse = reverse, range = range, |
| 541 | 5x |
midpoint = midpoint, ...) |
| 542 |
} |
|
| 543 |
} |
|
| 544 | ||
| 545 |
#' @export |
|
| 546 |
#' @rdname scale_tol_sunset |
|
| 547 |
scale_edge_colour_sunset <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 548 |
midpoint = 0, discrete = FALSE, |
|
| 549 |
aesthetics = "edge_colour") {
|
|
| 550 | 7x |
if (discrete) {
|
| 551 | ! |
scale_discrete(aesthetics, "sunset", reverse = reverse, ...) |
| 552 |
} else {
|
|
| 553 | 7x |
scale_continuous(aesthetics, "sunset", guide = "edge_colourbar", |
| 554 | 7x |
reverse = reverse, range = range, midpoint = midpoint, ...) |
| 555 |
} |
|
| 556 |
} |
|
| 557 | ||
| 558 |
#' @export |
|
| 559 |
#' @rdname scale_tol_sunset |
|
| 560 |
scale_edge_color_sunset <- scale_edge_colour_sunset |
|
| 561 | ||
| 562 |
#' @export |
|
| 563 |
#' @rdname scale_tol_sunset |
|
| 564 |
scale_edge_fill_sunset <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 565 |
midpoint = 0, discrete = FALSE, |
|
| 566 |
aesthetics = "edge_fill") {
|
|
| 567 | 5x |
if (discrete) {
|
| 568 | ! |
scale_discrete(aesthetics, "sunset", reverse = reverse, ...) |
| 569 |
} else {
|
|
| 570 | 5x |
scale_continuous(aesthetics, "sunset", guide = "edge_colourbar", |
| 571 | 5x |
reverse = reverse, range = range, midpoint = midpoint, ...) |
| 572 |
} |
|
| 573 |
} |
|
| 574 | ||
| 575 |
## Nightfall ---------------------------------------------------------------------- |
|
| 576 |
#' Paul Tol's *nightfall* Diverging Color Scheme |
|
| 577 |
#' |
|
| 578 |
#' @inheritParams scale_tol_sunset |
|
| 579 |
#' @inheritSection tol Diverging Color Schemes |
|
| 580 |
#' @return A [continuous][ggplot2::continuous_scale] scale. |
|
| 581 |
#' @references |
|
| 582 |
#' Tol, P. (2018). *Colour Schemes*. SRON. Technical Note No. |
|
| 583 |
#' SRON/EPS/TN/09-002, issue 3.1. |
|
| 584 |
#' URL: \url{https://sronpersonalpages.nl/~pault/data/colourschemes.pdf}
|
|
| 585 |
#' @example inst/examples/ex-tol-diverging.R |
|
| 586 |
#' @author N. Frerebeau |
|
| 587 |
#' @family diverging color schemes |
|
| 588 |
#' @family Paul Tol's color schemes |
|
| 589 |
#' @name scale_tol_nightfall |
|
| 590 |
#' @rdname scale_tol_nightfall |
|
| 591 |
NULL |
|
| 592 | ||
| 593 |
#' @export |
|
| 594 |
#' @rdname scale_tol_nightfall |
|
| 595 |
scale_colour_nightfall <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 596 |
midpoint = 0, discrete = FALSE, |
|
| 597 |
aesthetics = "colour") {
|
|
| 598 | 7x |
if (discrete) {
|
| 599 | ! |
scale_discrete(aesthetics, "nightfall", reverse = reverse, ...) |
| 600 |
} else {
|
|
| 601 | 7x |
scale_continuous(aesthetics, "nightfall", reverse = reverse, range = range, |
| 602 | 7x |
midpoint = midpoint, ...) |
| 603 |
} |
|
| 604 |
} |
|
| 605 | ||
| 606 |
#' @export |
|
| 607 |
#' @rdname scale_tol_nightfall |
|
| 608 |
scale_color_nightfall <- scale_colour_nightfall |
|
| 609 | ||
| 610 |
#' @export |
|
| 611 |
#' @rdname scale_tol_nightfall |
|
| 612 |
scale_fill_nightfall <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 613 |
midpoint = 0, discrete = FALSE, |
|
| 614 |
aesthetics = "fill") {
|
|
| 615 | 5x |
if (discrete) {
|
| 616 | ! |
scale_discrete(aesthetics, "nightfall", reverse = reverse, ...) |
| 617 |
} else {
|
|
| 618 | 5x |
scale_continuous(aesthetics, "nightfall", reverse = reverse, range = range, |
| 619 | 5x |
midpoint = midpoint, ...) |
| 620 |
} |
|
| 621 |
} |
|
| 622 | ||
| 623 |
#' @export |
|
| 624 |
#' @rdname scale_tol_nightfall |
|
| 625 |
scale_edge_colour_nightfall <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 626 |
midpoint = 0, discrete = FALSE, |
|
| 627 |
aesthetics = "edge_colour") {
|
|
| 628 | 7x |
if (discrete) {
|
| 629 | ! |
scale_discrete(aesthetics, "nightfall", reverse = reverse, ...) |
| 630 |
} else {
|
|
| 631 | 7x |
scale_continuous(aesthetics, "nightfall", guide = "edge_colourbar", |
| 632 | 7x |
reverse = reverse, range = range, midpoint = midpoint, ...) |
| 633 |
} |
|
| 634 |
} |
|
| 635 | ||
| 636 |
#' @export |
|
| 637 |
#' @rdname scale_tol_nightfall |
|
| 638 |
scale_edge_color_nightfall <- scale_edge_colour_nightfall |
|
| 639 | ||
| 640 |
#' @export |
|
| 641 |
#' @rdname scale_tol_nightfall |
|
| 642 |
scale_edge_fill_nightfall <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 643 |
midpoint = 0, discrete = FALSE, |
|
| 644 |
aesthetics = "edge_fill") {
|
|
| 645 | 5x |
if (discrete) {
|
| 646 | ! |
scale_discrete(aesthetics, "nightfall", reverse = reverse, ...) |
| 647 |
} else {
|
|
| 648 | 5x |
scale_continuous(aesthetics, "nightfall", guide = "edge_colourbar", |
| 649 | 5x |
reverse = reverse, range = range, midpoint = midpoint, ...) |
| 650 |
} |
|
| 651 |
} |
|
| 652 | ||
| 653 |
## BuRd ------------------------------------------------------------------------ |
|
| 654 |
#' Paul Tol's *BuRd* Diverging Color Scheme |
|
| 655 |
#' |
|
| 656 |
#' @inheritParams scale_tol_sunset |
|
| 657 |
#' @inheritSection tol Diverging Color Schemes |
|
| 658 |
#' @return A [continuous][ggplot2::continuous_scale] scale. |
|
| 659 |
#' @references |
|
| 660 |
#' Tol, P. (2018). *Colour Schemes*. SRON. Technical Note No. |
|
| 661 |
#' SRON/EPS/TN/09-002, issue 3.1. |
|
| 662 |
#' URL: \url{https://sronpersonalpages.nl/~pault/data/colourschemes.pdf}
|
|
| 663 |
#' @example inst/examples/ex-tol-diverging.R |
|
| 664 |
#' @author N. Frerebeau |
|
| 665 |
#' @family diverging color schemes |
|
| 666 |
#' @family Paul Tol's color schemes |
|
| 667 |
#' @name scale_tol_BuRd |
|
| 668 |
#' @rdname scale_tol_BuRd |
|
| 669 |
NULL |
|
| 670 | ||
| 671 |
#' @export |
|
| 672 |
#' @rdname scale_tol_BuRd |
|
| 673 |
scale_colour_BuRd <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 674 |
midpoint = 0, discrete = FALSE, |
|
| 675 |
aesthetics = "colour") {
|
|
| 676 | 8x |
if (discrete) {
|
| 677 | ! |
scale_discrete(aesthetics, "BuRd", reverse = reverse, ...) |
| 678 |
} else {
|
|
| 679 | 8x |
scale_continuous(aesthetics, "BuRd", reverse = reverse, range = range, |
| 680 | 8x |
midpoint = midpoint, ...) |
| 681 |
} |
|
| 682 |
} |
|
| 683 | ||
| 684 |
#' @export |
|
| 685 |
#' @rdname scale_tol_BuRd |
|
| 686 |
scale_color_BuRd <- scale_colour_BuRd |
|
| 687 | ||
| 688 |
#' @export |
|
| 689 |
#' @rdname scale_tol_BuRd |
|
| 690 |
scale_fill_BuRd <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 691 |
midpoint = 0, discrete = FALSE, |
|
| 692 |
aesthetics = "fill") {
|
|
| 693 | 5x |
if (discrete) {
|
| 694 | ! |
scale_discrete(aesthetics, "BuRd", reverse = reverse, ...) |
| 695 |
} else {
|
|
| 696 | 5x |
scale_continuous(aesthetics, "BuRd", reverse = reverse, range = range, |
| 697 | 5x |
midpoint = midpoint, ...) |
| 698 |
} |
|
| 699 |
} |
|
| 700 | ||
| 701 |
#' @export |
|
| 702 |
#' @rdname scale_tol_BuRd |
|
| 703 |
scale_edge_colour_BuRd <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 704 |
midpoint = 0, discrete = FALSE, |
|
| 705 |
aesthetics = "edge_colour") {
|
|
| 706 | 8x |
if (discrete) {
|
| 707 | ! |
scale_discrete(aesthetics, "BuRd", reverse = reverse, ...) |
| 708 |
} else {
|
|
| 709 | 8x |
scale_continuous(aesthetics, "BuRd", guide = "edge_colourbar", |
| 710 | 8x |
reverse = reverse, range = range, midpoint = midpoint, ...) |
| 711 |
} |
|
| 712 |
} |
|
| 713 | ||
| 714 |
#' @export |
|
| 715 |
#' @rdname scale_tol_BuRd |
|
| 716 |
scale_edge_color_BuRd <- scale_edge_colour_BuRd |
|
| 717 | ||
| 718 |
#' @export |
|
| 719 |
#' @rdname scale_tol_BuRd |
|
| 720 |
scale_edge_fill_BuRd <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 721 |
midpoint = 0, discrete = FALSE, |
|
| 722 |
aesthetics = "edge_fill") {
|
|
| 723 | 5x |
if (discrete) {
|
| 724 | ! |
scale_discrete(aesthetics, "BuRd", reverse = reverse, ...) |
| 725 |
} else {
|
|
| 726 | 5x |
scale_continuous(aesthetics, "BuRd", guide = "edge_colourbar", |
| 727 | 5x |
reverse = reverse, range = range, midpoint = midpoint, ...) |
| 728 |
} |
|
| 729 |
} |
|
| 730 | ||
| 731 |
## PRGn ------------------------------------------------------------------------ |
|
| 732 |
#' Paul Tol's *PRGn* Diverging Color Scheme |
|
| 733 |
#' |
|
| 734 |
#' @inheritParams scale_tol_sunset |
|
| 735 |
#' @inheritSection tol Diverging Color Schemes |
|
| 736 |
#' @return A [continuous][ggplot2::continuous_scale] scale. |
|
| 737 |
#' @references |
|
| 738 |
#' Tol, P. (2018). *Colour Schemes*. SRON. Technical Note No. |
|
| 739 |
#' SRON/EPS/TN/09-002, issue 3.1. |
|
| 740 |
#' URL: \url{https://sronpersonalpages.nl/~pault/data/colourschemes.pdf}
|
|
| 741 |
#' @example inst/examples/ex-tol-diverging.R |
|
| 742 |
#' @author N. Frerebeau |
|
| 743 |
#' @family diverging color schemes |
|
| 744 |
#' @family Paul Tol's color schemes |
|
| 745 |
#' @name scale_tol_PRGn |
|
| 746 |
#' @rdname scale_tol_PRGn |
|
| 747 |
NULL |
|
| 748 | ||
| 749 |
#' @export |
|
| 750 |
#' @rdname scale_tol_PRGn |
|
| 751 |
scale_colour_PRGn <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 752 |
midpoint = 0, discrete = FALSE, |
|
| 753 |
aesthetics = "colour") {
|
|
| 754 | 8x |
if (discrete) {
|
| 755 | ! |
scale_discrete(aesthetics, "PRGn", reverse = reverse, ...) |
| 756 |
} else {
|
|
| 757 | 8x |
scale_continuous(aesthetics, "PRGn", reverse = reverse, range = range, |
| 758 | 8x |
midpoint = midpoint, ...) |
| 759 |
} |
|
| 760 |
} |
|
| 761 | ||
| 762 |
#' @export |
|
| 763 |
#' @rdname scale_tol_PRGn |
|
| 764 |
scale_color_PRGn <- scale_colour_PRGn |
|
| 765 | ||
| 766 |
#' @export |
|
| 767 |
#' @rdname scale_tol_PRGn |
|
| 768 |
scale_fill_PRGn <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 769 |
midpoint = 0, discrete = FALSE, |
|
| 770 |
aesthetics = "fill") {
|
|
| 771 | 5x |
if (discrete) {
|
| 772 | ! |
scale_discrete(aesthetics, "PRGn", reverse = reverse, ...) |
| 773 |
} else {
|
|
| 774 | 5x |
scale_continuous(aesthetics, "PRGn", reverse = reverse, range = range, |
| 775 | 5x |
midpoint = midpoint, ...) |
| 776 |
} |
|
| 777 |
} |
|
| 778 | ||
| 779 |
#' @export |
|
| 780 |
#' @rdname scale_tol_PRGn |
|
| 781 |
scale_edge_colour_PRGn <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 782 |
midpoint = 0, discrete = FALSE, |
|
| 783 |
aesthetics = "edge_colour") {
|
|
| 784 | 8x |
if (discrete) {
|
| 785 | ! |
scale_discrete(aesthetics, "PRGn", reverse = reverse, ...) |
| 786 |
} else {
|
|
| 787 | 8x |
scale_continuous(aesthetics, "PRGn", guide = "edge_colourbar", |
| 788 | 8x |
reverse = reverse, range = range, midpoint = midpoint, ...) |
| 789 |
} |
|
| 790 |
} |
|
| 791 | ||
| 792 |
#' @export |
|
| 793 |
#' @rdname scale_tol_PRGn |
|
| 794 |
scale_edge_color_PRGn <- scale_edge_colour_PRGn |
|
| 795 | ||
| 796 |
#' @export |
|
| 797 |
#' @rdname scale_tol_PRGn |
|
| 798 |
scale_edge_fill_PRGn <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 799 |
midpoint = 0, discrete = FALSE, |
|
| 800 |
aesthetics = "edge_fill") {
|
|
| 801 | 5x |
if (discrete) {
|
| 802 | ! |
scale_discrete(aesthetics, "PRGn", reverse = reverse, ...) |
| 803 |
} else {
|
|
| 804 | 5x |
scale_continuous(aesthetics, "PRGn", guide = "edge_colourbar", |
| 805 | 5x |
reverse = reverse, range = range, midpoint = midpoint, ...) |
| 806 |
} |
|
| 807 |
} |
|
| 808 | ||
| 809 |
# Sequential =================================================================== |
|
| 810 |
## YlOrBr ---------------------------------------------------------------------- |
|
| 811 |
#' Paul Tol's *YlOrBr* Sequential Color Scheme |
|
| 812 |
#' |
|
| 813 |
#' @param ... Arguments passed to [ggplot2::continuous_scale()]. |
|
| 814 |
#' @param reverse A [`logical`] scalar. Should the resulting |
|
| 815 |
#' vector of colors be reversed? |
|
| 816 |
#' @param range A length-two [`numeric`] vector specifying the |
|
| 817 |
#' fraction of the scheme's color domain to keep. |
|
| 818 |
#' @param aesthetics A [`character`] string or vector of character |
|
| 819 |
#' strings listing the name(s) of the aesthetic(s) that this scale works with. |
|
| 820 |
#' @param discrete A [`logical`] scalar: should the color scheme be |
|
| 821 |
#' used as a discrete scale? If `TRUE`, it is a departure from Paul Tol's |
|
| 822 |
#' recommendations and likely a very poor use of color. |
|
| 823 |
#' @inheritSection tol Sequential Color Schemes |
|
| 824 |
#' @return A [continuous][ggplot2::continuous_scale] scale. |
|
| 825 |
#' @references |
|
| 826 |
#' Tol, P. (2018). *Colour Schemes*. SRON. Technical Note No. |
|
| 827 |
#' SRON/EPS/TN/09-002, issue 3.1. |
|
| 828 |
#' URL: \url{https://sronpersonalpages.nl/~pault/data/colourschemes.pdf}
|
|
| 829 |
#' @example inst/examples/ex-tol-sequential.R |
|
| 830 |
#' @author N. Frerebeau |
|
| 831 |
#' @family sequential color schemes |
|
| 832 |
#' @family Paul Tol's color schemes |
|
| 833 |
#' @name scale_tol_YlOrBr |
|
| 834 |
#' @rdname scale_tol_YlOrBr |
|
| 835 |
NULL |
|
| 836 | ||
| 837 |
#' @export |
|
| 838 |
#' @rdname scale_tol_YlOrBr |
|
| 839 |
scale_colour_YlOrBr <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 840 |
discrete = FALSE, aesthetics = "colour") {
|
|
| 841 | 7x |
if (discrete) {
|
| 842 | 1x |
scale_discrete(aesthetics, "YlOrBr", reverse = reverse, ...) |
| 843 |
} else {
|
|
| 844 | 6x |
scale_continuous(aesthetics, "YlOrBr", reverse = reverse, |
| 845 | 6x |
range = range, ...) |
| 846 |
} |
|
| 847 |
} |
|
| 848 | ||
| 849 |
#' @export |
|
| 850 |
#' @rdname scale_tol_YlOrBr |
|
| 851 |
scale_color_YlOrBr <- scale_colour_YlOrBr |
|
| 852 | ||
| 853 |
#' @export |
|
| 854 |
#' @rdname scale_tol_YlOrBr |
|
| 855 |
scale_fill_YlOrBr <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 856 |
discrete = FALSE, aesthetics = "fill") {
|
|
| 857 | 6x |
if (discrete) {
|
| 858 | 1x |
scale_discrete(aesthetics, "YlOrBr", reverse = reverse, ...) |
| 859 |
} else {
|
|
| 860 | 5x |
scale_continuous(aesthetics, "YlOrBr", reverse = reverse, |
| 861 | 5x |
range = range, ...) |
| 862 |
} |
|
| 863 |
} |
|
| 864 | ||
| 865 |
#' @export |
|
| 866 |
#' @rdname scale_tol_YlOrBr |
|
| 867 |
scale_edge_colour_YlOrBr <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 868 |
discrete = FALSE, |
|
| 869 |
aesthetics = "edge_colour") {
|
|
| 870 | 7x |
if (discrete) {
|
| 871 | 1x |
scale_discrete(aesthetics, "YlOrBr", reverse = reverse, ...) |
| 872 |
} else {
|
|
| 873 | 6x |
scale_continuous(aesthetics, "YlOrBr", guide = "edge_colourbar", |
| 874 | 6x |
reverse = reverse, range = range, ...) |
| 875 |
} |
|
| 876 |
} |
|
| 877 | ||
| 878 |
#' @export |
|
| 879 |
#' @rdname scale_tol_YlOrBr |
|
| 880 |
scale_edge_color_YlOrBr <- scale_edge_colour_YlOrBr |
|
| 881 | ||
| 882 |
#' @export |
|
| 883 |
#' @rdname scale_tol_YlOrBr |
|
| 884 |
scale_edge_fill_YlOrBr <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 885 |
discrete = FALSE, |
|
| 886 |
aesthetics = "edge_fill") {
|
|
| 887 | 6x |
if (discrete) {
|
| 888 | 1x |
scale_discrete(aesthetics, "YlOrBr", reverse = reverse, ...) |
| 889 |
} else {
|
|
| 890 | 5x |
scale_continuous(aesthetics, "YlOrBr", guide = "edge_colourbar", |
| 891 | 5x |
reverse = reverse, range = range, ...) |
| 892 |
} |
|
| 893 |
} |
|
| 894 | ||
| 895 |
## Iridescent ------------------------------------------------------------------ |
|
| 896 |
#' Paul Tol's *iridescent* Sequential Color Scheme |
|
| 897 |
#' |
|
| 898 |
#' @inheritParams scale_colour_YlOrBr |
|
| 899 |
#' @inheritSection tol Sequential Color Schemes |
|
| 900 |
#' @return A [continuous][ggplot2::continuous_scale] scale. |
|
| 901 |
#' @references |
|
| 902 |
#' Tol, P. (2018). *Colour Schemes*. SRON. Technical Note No. |
|
| 903 |
#' SRON/EPS/TN/09-002, issue 3.1. |
|
| 904 |
#' URL: \url{https://sronpersonalpages.nl/~pault/data/colourschemes.pdf}
|
|
| 905 |
#' @example inst/examples/ex-tol-sequential.R |
|
| 906 |
#' @author N. Frerebeau |
|
| 907 |
#' @family sequential color schemes |
|
| 908 |
#' @family Paul Tol's color schemes |
|
| 909 |
#' @name scale_tol_iridescent |
|
| 910 |
#' @rdname scale_tol_iridescent |
|
| 911 |
NULL |
|
| 912 | ||
| 913 |
#' @export |
|
| 914 |
#' @rdname scale_tol_iridescent |
|
| 915 |
scale_colour_iridescent <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 916 |
discrete = FALSE, aesthetics = "colour") {
|
|
| 917 | 7x |
if (discrete) {
|
| 918 | 1x |
scale_discrete(aesthetics, "iridescent", reverse = reverse, ...) |
| 919 |
} else {
|
|
| 920 | 6x |
scale_continuous(aesthetics, "iridescent", reverse = reverse, |
| 921 | 6x |
range = range, ...) |
| 922 |
} |
|
| 923 |
} |
|
| 924 | ||
| 925 |
#' @export |
|
| 926 |
#' @rdname scale_tol_iridescent |
|
| 927 |
scale_color_iridescent <- scale_colour_iridescent |
|
| 928 | ||
| 929 |
#' @export |
|
| 930 |
#' @rdname scale_tol_iridescent |
|
| 931 |
scale_fill_iridescent <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 932 |
discrete = FALSE, aesthetics = "fill") {
|
|
| 933 | 4x |
if (discrete) {
|
| 934 | 1x |
scale_discrete(aesthetics, "iridescent", reverse = reverse, ...) |
| 935 |
} else {
|
|
| 936 | 3x |
scale_continuous(aesthetics, "iridescent", reverse = reverse, |
| 937 | 3x |
range = range, ...) |
| 938 |
} |
|
| 939 |
} |
|
| 940 | ||
| 941 |
#' @export |
|
| 942 |
#' @rdname scale_tol_iridescent |
|
| 943 |
scale_edge_colour_iridescent <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 944 |
discrete = FALSE, |
|
| 945 |
aesthetics = "edge_colour") {
|
|
| 946 | 7x |
if (discrete) {
|
| 947 | 1x |
scale_discrete(aesthetics, "iridescent", reverse = reverse, ...) |
| 948 |
} else {
|
|
| 949 | 6x |
scale_continuous(aesthetics, "iridescent", guide = "edge_colourbar", |
| 950 | 6x |
reverse = reverse, range = range, ...) |
| 951 |
} |
|
| 952 |
} |
|
| 953 | ||
| 954 |
#' @export |
|
| 955 |
#' @rdname scale_tol_iridescent |
|
| 956 |
scale_edge_color_iridescent <- scale_edge_colour_iridescent |
|
| 957 | ||
| 958 |
#' @export |
|
| 959 |
#' @rdname scale_tol_iridescent |
|
| 960 |
scale_edge_fill_iridescent <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 961 |
discrete = FALSE, |
|
| 962 |
aesthetics = "edge_fill") {
|
|
| 963 | 4x |
if (discrete) {
|
| 964 | 1x |
scale_discrete(aesthetics, "iridescent", reverse = reverse, ...) |
| 965 |
} else {
|
|
| 966 | 3x |
scale_continuous(aesthetics, "iridescent", guide = "edge_colourbar", |
| 967 | 3x |
reverse = reverse, range = range, ...) |
| 968 |
} |
|
| 969 |
} |
|
| 970 | ||
| 971 |
## Incandescent ------------------------------------------------------------------ |
|
| 972 |
#' Paul Tol's *incandescent* Sequential Color Scheme |
|
| 973 |
#' |
|
| 974 |
#' @inheritParams scale_colour_YlOrBr |
|
| 975 |
#' @inheritSection tol Sequential Color Schemes |
|
| 976 |
#' @return A [continuous][ggplot2::continuous_scale] scale. |
|
| 977 |
#' @references |
|
| 978 |
#' Tol, P. (2018). *Colour Schemes*. SRON. Technical Note No. |
|
| 979 |
#' SRON/EPS/TN/09-002, issue 3.1. |
|
| 980 |
#' URL: \url{https://sronpersonalpages.nl/~pault/data/colourschemes.pdf}
|
|
| 981 |
#' @example inst/examples/ex-tol-sequential.R |
|
| 982 |
#' @author N. Frerebeau |
|
| 983 |
#' @family sequential color schemes |
|
| 984 |
#' @family Paul Tol's color schemes |
|
| 985 |
#' @name scale_tol_incandescent |
|
| 986 |
#' @rdname scale_tol_incandescent |
|
| 987 |
NULL |
|
| 988 | ||
| 989 |
#' @export |
|
| 990 |
#' @rdname scale_tol_incandescent |
|
| 991 |
scale_colour_incandescent <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 992 |
discrete = FALSE, aesthetics = "colour") {
|
|
| 993 | 7x |
if (discrete) {
|
| 994 | 1x |
scale_discrete(aesthetics, "incandescent", reverse = reverse, ...) |
| 995 |
} else {
|
|
| 996 | 6x |
scale_continuous(aesthetics, "incandescent", reverse = reverse, |
| 997 | 6x |
range = range, ...) |
| 998 |
} |
|
| 999 |
} |
|
| 1000 | ||
| 1001 |
#' @export |
|
| 1002 |
#' @rdname scale_tol_incandescent |
|
| 1003 |
scale_color_incandescent <- scale_colour_incandescent |
|
| 1004 | ||
| 1005 |
#' @export |
|
| 1006 |
#' @rdname scale_tol_incandescent |
|
| 1007 |
scale_fill_incandescent <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1008 |
discrete = FALSE, aesthetics = "fill") {
|
|
| 1009 | 4x |
if (discrete) {
|
| 1010 | 1x |
scale_discrete(aesthetics, "incandescent", reverse = reverse, ...) |
| 1011 |
} else {
|
|
| 1012 | 3x |
scale_continuous(aesthetics, "incandescent", reverse = reverse, |
| 1013 | 3x |
range = range, ...) |
| 1014 |
} |
|
| 1015 |
} |
|
| 1016 | ||
| 1017 |
#' @export |
|
| 1018 |
#' @rdname scale_tol_incandescent |
|
| 1019 |
scale_edge_colour_incandescent <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1020 |
discrete = FALSE, |
|
| 1021 |
aesthetics = "edge_colour") {
|
|
| 1022 | 7x |
if (discrete) {
|
| 1023 | 1x |
scale_discrete(aesthetics, "incandescent", reverse = reverse, ...) |
| 1024 |
} else {
|
|
| 1025 | 6x |
scale_continuous(aesthetics, "incandescent", guide = "edge_colourbar", |
| 1026 | 6x |
reverse = reverse, range = range, ...) |
| 1027 |
} |
|
| 1028 |
} |
|
| 1029 | ||
| 1030 |
#' @export |
|
| 1031 |
#' @rdname scale_tol_incandescent |
|
| 1032 |
scale_edge_color_incandescent <- scale_edge_colour_incandescent |
|
| 1033 | ||
| 1034 |
#' @export |
|
| 1035 |
#' @rdname scale_tol_incandescent |
|
| 1036 |
scale_edge_fill_incandescent <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1037 |
discrete = FALSE, |
|
| 1038 |
aesthetics = "edge_fill") {
|
|
| 1039 | 4x |
if (discrete) {
|
| 1040 | 1x |
scale_discrete(aesthetics, "incandescent", reverse = reverse, ...) |
| 1041 |
} else {
|
|
| 1042 | 3x |
scale_continuous(aesthetics, "incandescent", guide = "edge_colourbar", |
| 1043 | 3x |
reverse = reverse, range = range, ...) |
| 1044 |
} |
|
| 1045 |
} |
|
| 1046 | ||
| 1047 |
## Smooth Rainbow -------------------------------------------------------------- |
|
| 1048 |
#' Paul Tol's *smooth rainbow* Sequential Color Scheme |
|
| 1049 |
#' |
|
| 1050 |
#' @inheritParams scale_colour_YlOrBr |
|
| 1051 |
#' @inheritSection tol Sequential Color Schemes |
|
| 1052 |
#' @inheritSection tol Rainbow Color Scheme |
|
| 1053 |
#' @return A [continuous][ggplot2::continuous_scale] scale. |
|
| 1054 |
#' @references |
|
| 1055 |
#' Tol, P. (2018). *Colour Schemes*. SRON. Technical Note No. |
|
| 1056 |
#' SRON/EPS/TN/09-002, issue 3.1. |
|
| 1057 |
#' URL: \url{https://sronpersonalpages.nl/~pault/data/colourschemes.pdf}
|
|
| 1058 |
#' @example inst/examples/ex-tol-sequential.R |
|
| 1059 |
#' @author N. Frerebeau |
|
| 1060 |
#' @family sequential color schemes |
|
| 1061 |
#' @family Paul Tol's color schemes |
|
| 1062 |
#' @name scale_tol_smoothrainbow |
|
| 1063 |
#' @rdname scale_tol_smoothrainbow |
|
| 1064 |
NULL |
|
| 1065 | ||
| 1066 |
#' @export |
|
| 1067 |
#' @rdname scale_tol_smoothrainbow |
|
| 1068 |
scale_colour_smoothrainbow <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1069 |
discrete = FALSE, aesthetics = "colour") {
|
|
| 1070 | 7x |
if (discrete) {
|
| 1071 | 1x |
scale_discrete(aesthetics, "smoothrainbow", reverse = reverse, ...) |
| 1072 |
} else {
|
|
| 1073 | 6x |
scale_continuous(aesthetics, "smoothrainbow", reverse = reverse, |
| 1074 | 6x |
range = range, ...) |
| 1075 |
} |
|
| 1076 |
} |
|
| 1077 | ||
| 1078 |
#' @export |
|
| 1079 |
#' @rdname scale_tol_smoothrainbow |
|
| 1080 |
scale_color_smoothrainbow <- scale_colour_smoothrainbow |
|
| 1081 | ||
| 1082 |
#' @export |
|
| 1083 |
#' @rdname scale_tol_smoothrainbow |
|
| 1084 |
scale_fill_smoothrainbow <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1085 |
discrete = FALSE, aesthetics = "fill") {
|
|
| 1086 | 4x |
if (discrete) {
|
| 1087 | 1x |
scale_discrete(aesthetics, "smooth rainbow", reverse = reverse, ...) |
| 1088 |
} else {
|
|
| 1089 | 3x |
scale_continuous(aesthetics, "smooth rainbow", reverse = reverse, |
| 1090 | 3x |
range = range, ...) |
| 1091 |
} |
|
| 1092 |
} |
|
| 1093 | ||
| 1094 |
#' @export |
|
| 1095 |
#' @rdname scale_tol_smoothrainbow |
|
| 1096 |
scale_edge_colour_smoothrainbow <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1097 |
discrete = FALSE, |
|
| 1098 |
aesthetics = "edge_colour") {
|
|
| 1099 | 7x |
if (discrete) {
|
| 1100 | 1x |
scale_discrete(aesthetics, "smoothrainbow", reverse = reverse, ...) |
| 1101 |
} else {
|
|
| 1102 | 6x |
scale_continuous(aesthetics, "smoothrainbow", guide = "edge_colourbar", |
| 1103 | 6x |
reverse = reverse, range = range, ...) |
| 1104 |
} |
|
| 1105 |
} |
|
| 1106 | ||
| 1107 |
#' @export |
|
| 1108 |
#' @rdname scale_tol_smoothrainbow |
|
| 1109 |
scale_edge_color_smoothrainbow <- scale_edge_colour_smoothrainbow |
|
| 1110 | ||
| 1111 |
#' @export |
|
| 1112 |
#' @rdname scale_tol_smoothrainbow |
|
| 1113 |
scale_edge_fill_smoothrainbow <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1114 |
discrete = FALSE, |
|
| 1115 |
aesthetics = "edge_fill") {
|
|
| 1116 | 4x |
if (discrete) {
|
| 1117 | 1x |
scale_discrete(aesthetics, "smoothrainbow", reverse = reverse, ...) |
| 1118 |
} else {
|
|
| 1119 | 3x |
scale_continuous(aesthetics, "smoothrainbow", guide = "edge_colourbar", |
| 1120 | 3x |
reverse = reverse, range = range, ...) |
| 1121 |
} |
|
| 1122 |
} |
| 1 |
#' Plot Color Scheme |
|
| 2 |
#' |
|
| 3 |
#' Shows colors in a plot. |
|
| 4 |
#' @param x A [`character`] vector of colors. |
|
| 5 |
#' @param colours A [`logical`] scalar: should the hexadecimal representation of |
|
| 6 |
#' the colors be displayed? |
|
| 7 |
#' @param names A [`logical`] scalar: should the name of the colors be |
|
| 8 |
#' displayed? |
|
| 9 |
#' @param size A [`numeric`] value giving the amount by which plotting text |
|
| 10 |
#' should be magnified relative to the default. Works the same as `cex` |
|
| 11 |
#' parameter of [graphics::par()]. |
|
| 12 |
#' @return |
|
| 13 |
#' `plot_scheme()` is called for its side-effects: it results in a graphic |
|
| 14 |
#' being displayed (invisibly returns `x`). |
|
| 15 |
#' @example inst/examples/ex-plot.R |
|
| 16 |
#' @author N. Frerebeau |
|
| 17 |
#' @family diagnostic tools |
|
| 18 |
#' @export |
|
| 19 |
plot_scheme <- function(x, colours = FALSE, names = FALSE, size = 1) {
|
|
| 20 |
# Validation |
|
| 21 | 1x |
assert_color(x) |
| 22 | ||
| 23 |
# Save and restore graphical parameters |
|
| 24 | ! |
old_par <- graphics::par(no.readonly = TRUE) |
| 25 | ! |
on.exit(graphics::par(old_par)) |
| 26 | ||
| 27 | ! |
info <- colours && names |
| 28 | ! |
missing <- attr(x, "missing") |
| 29 | ! |
bad_data <- !is.null(missing) && !is.na(missing) |
| 30 | ! |
if (bad_data) x <- c(x, missing) |
| 31 | ||
| 32 | ! |
n <- length(x) # Number of colors |
| 33 | ! |
p <- seq(from = 1, by = 0.75, length.out = n) |
| 34 | ! |
q <- 1 - 0.43 * rep(c(0, 1), length.out = n) |
| 35 | ||
| 36 | ! |
graphics::par(mar = c(0, 0, 0, 0) + 0.1, xaxs = "i", yaxs = "i") |
| 37 | ! |
graphics::plot( |
| 38 | ! |
x = NULL, y = NULL, |
| 39 | ! |
xlim = c(0.5, max(p) + 0.5 + bad_data / 2), ylim = c(0, 1.5), |
| 40 | ! |
xlab = "", ylab = "", axes = FALSE, asp = 1 |
| 41 |
) |
|
| 42 | ||
| 43 | ! |
for (i in seq_len(n - bad_data)) {
|
| 44 |
#even <- i %% 2 == 0 |
|
| 45 | ! |
draw_hexagon(x = p[[i]], y = q[[i]], r = 0.5, border = NULL, fill = x[[i]]) |
| 46 |
} |
|
| 47 | ! |
if (bad_data) {
|
| 48 | ! |
draw_circle(x = p[[n]] + 0.5, y = q[[n]], r = 0.5, n = 200, |
| 49 | ! |
border = NULL, fill = missing) |
| 50 |
} |
|
| 51 | ! |
delta <- ifelse(colours && names && !is.null(names(x)), 0.1, 0) |
| 52 | ! |
if (colours) {
|
| 53 | ! |
if (bad_data) {
|
| 54 | ! |
graphics::text(x = p[[n]] + 0.5, y = q[[n]], labels = missing, cex = size) |
| 55 | ! |
x <- utils::head(x, -1) |
| 56 | ! |
p <- utils::head(p, -1) |
| 57 | ! |
q <- utils::head(q, -1) |
| 58 |
} |
|
| 59 | ! |
graphics::text(x = p, y = q - delta * info, labels = x, cex = size) |
| 60 |
} |
|
| 61 | ! |
if (names && !is.null(names(x))) {
|
| 62 | ! |
graphics::text(x = p, y = q + delta * info, labels = names(x), cex = size) |
| 63 |
} |
|
| 64 | ||
| 65 | ! |
invisible(x) |
| 66 |
} |
|
| 67 | ||
| 68 |
draw_hexagon <- function(x = 0, y = 0, r = 0.5, border = NULL, fill = NA) {
|
|
| 69 | ! |
vertices <- seq_len(6) |
| 70 | ! |
graphics::polygon( |
| 71 | ! |
x = x + r * cos(vertices * 2 * pi / 6), |
| 72 | ! |
y = y + r * sin(vertices * 2 * pi / 6), |
| 73 | ! |
border = border, |
| 74 | ! |
col = fill |
| 75 |
) |
|
| 76 |
} |
|
| 77 |
draw_circle <- function(x = 0, y = 0, r = 0.5, n = 200, |
|
| 78 |
border = NULL, fill = NA) {
|
|
| 79 | ! |
theta <- seq(0, 2 * pi, length.out = n) |
| 80 | ! |
graphics::polygon( |
| 81 | ! |
x = r * cos(theta) + x, |
| 82 | ! |
y = r * sin(theta) + y, |
| 83 | ! |
border = border, |
| 84 | ! |
col = fill |
| 85 |
) |
|
| 86 |
} |
| 1 |
# Color scales constructor for ggplot2 |
|
| 2 |
#' @include color.R |
|
| 3 |
NULL |
|
| 4 | ||
| 5 |
#' Color Scale Builder |
|
| 6 |
#' |
|
| 7 |
#' Builds a color scale for \pkg{ggplot2} or \pkg{ggraph}.
|
|
| 8 |
#' @param palette A [`character`] string giving the name of the color scheme to |
|
| 9 |
#' be used (see [info()]). |
|
| 10 |
#' @param ... Extra parameters to be passed to the color scale function. |
|
| 11 |
#' @return A [discrete][ggplot2::discrete_scale] or |
|
| 12 |
#' [continuous][ggplot2::continuous_scale] scale. |
|
| 13 |
#' @example inst/examples/ex-pick.R |
|
| 14 |
#' @author N. Frerebeau |
|
| 15 |
#' @family ggplot2 scales |
|
| 16 |
#' @name scale_picker |
|
| 17 |
#' @rdname scale_picker |
|
| 18 |
NULL |
|
| 19 | ||
| 20 |
#' @export |
|
| 21 |
#' @rdname scale_picker |
|
| 22 |
scale_colour_picker <- function(..., palette = "YlOrBr") {
|
|
| 23 | 4x |
fun <- sprintf("scale_colour_%s", palette)
|
| 24 | 4x |
do.call(fun, args = list(...)) |
| 25 |
} |
|
| 26 | ||
| 27 |
#' @export |
|
| 28 |
#' @rdname scale_picker |
|
| 29 |
scale_color_picker <- scale_colour_picker |
|
| 30 | ||
| 31 |
#' @export |
|
| 32 |
#' @rdname scale_picker |
|
| 33 |
scale_fill_picker <- function(..., palette = "YlOrBr") {
|
|
| 34 | 1x |
fun <- sprintf("scale_fill_%s", palette)
|
| 35 | 1x |
do.call(fun, args = list(...)) |
| 36 |
} |
|
| 37 | ||
| 38 |
#' @export |
|
| 39 |
#' @rdname scale_picker |
|
| 40 |
scale_edge_colour_picker <- function(..., palette = "YlOrBr") {
|
|
| 41 | 1x |
fun <- sprintf("scale_edge_colour_%s", palette)
|
| 42 | 1x |
do.call(fun, args = list(...)) |
| 43 |
} |
|
| 44 | ||
| 45 |
#' @export |
|
| 46 |
#' @rdname scale_picker |
|
| 47 |
scale_edge_color_picker <- scale_edge_colour_picker |
|
| 48 | ||
| 49 |
#' @export |
|
| 50 |
#' @rdname scale_picker |
|
| 51 |
scale_edge_fill_picker <- function(..., palette = "YlOrBr") {
|
|
| 52 | 1x |
fun <- sprintf("scale_edge_fill_%s", palette)
|
| 53 | 1x |
do.call(fun, args = list(...)) |
| 54 |
} |
|
| 55 | ||
| 56 |
#' Color Scale Constructors |
|
| 57 |
#' |
|
| 58 |
#' Builds a discrete or continuous scale for \pkg{ggplot2} according to the
|
|
| 59 |
#' color scheme used. |
|
| 60 |
#' @param aesthetics The names of the aesthetics that this scale works with. |
|
| 61 |
#' @param scheme A [`character`] string giving the name of the scheme to be |
|
| 62 |
#' used (see [color()]). |
|
| 63 |
#' @param guide A [`function`] used to create a guide or its name. |
|
| 64 |
#' See [ggplot2::guides()] for more information. |
|
| 65 |
#' @param reverse A [`logical`] scalar: should the resulting vector of colors |
|
| 66 |
#' should be reversed? |
|
| 67 |
#' @param use_names A [`logical`] scalar: should the names of the colors be |
|
| 68 |
#' preserved? |
|
| 69 |
#' @param lang A [`character`] string specifying the language for the color |
|
| 70 |
#' names. It must be one of "`en`" (english, the default) or "`fr`" (french). |
|
| 71 |
#' @param type A [`character`] string specifying the scale to be |
|
| 72 |
#' build. It must be one of "`auto`" (the default), "`discrete`" or |
|
| 73 |
#' "`continuous`". "`discrete`" allows to use a continuous color scheme with |
|
| 74 |
#' discrete data. "`continuous`" allows to use a discrete color scheme with |
|
| 75 |
#' continuous data (forces interpolation; see [color()]). |
|
| 76 |
#' @param midpoint A [`numeric`] value specifying the midpoint (in |
|
| 77 |
#' data value) of the diverging scale (defaults to \eqn{0}).
|
|
| 78 |
#' @param ... Further arguments passed to [ggplot2::discrete_scale()] |
|
| 79 |
#' or [ggplot2::continuous_scale()], used respectively for qualitative data |
|
| 80 |
#' and diverging/sequential data. |
|
| 81 |
#' @return A [discrete][ggplot2::discrete_scale()] |
|
| 82 |
#' or [continuous][ggplot2::continuous_scale()] scale. |
|
| 83 |
#' @author N. Frerebeau |
|
| 84 |
#' @keywords internal |
|
| 85 |
#' @noRd |
|
| 86 |
NULL |
|
| 87 | ||
| 88 |
scale_discrete <- function(aesthetics, scheme, guide = "legend", |
|
| 89 |
reverse = FALSE, use_names = FALSE, |
|
| 90 |
lang = "en", ...) {
|
|
| 91 |
# Check if ggplot2 is installed |
|
| 92 | 288x |
assert_package("ggplot2")
|
| 93 | ||
| 94 |
# Get color scheme |
|
| 95 | 288x |
palette <- color(scheme, reverse = reverse, names = use_names, lang = lang) |
| 96 | ||
| 97 |
# Build scale |
|
| 98 | 288x |
scale_args <- list(...) |
| 99 | 288x |
scale_args$guide <- guide |
| 100 | 288x |
scale_args$na.value <- scale_args$na.value %||% attr(palette, "missing") |
| 101 | ||
| 102 | 288x |
do.call( |
| 103 | 288x |
ggplot2::discrete_scale, |
| 104 | 288x |
c(aesthetics = aesthetics, palette = palette, scale_args) |
| 105 |
) |
|
| 106 |
} |
|
| 107 | ||
| 108 |
scale_continuous <- function(aesthetics, scheme, guide = "colourbar", |
|
| 109 |
reverse = FALSE, range = c(0, 1), midpoint = 0, |
|
| 110 |
lang = "en", ...) {
|
|
| 111 |
# Validation |
|
| 112 | 666x |
assert_package("ggplot2") # Check if ggplot2 is installed
|
| 113 | 286x |
if (guide == "edge_colourbar") assert_package("ggraph")
|
| 114 | ||
| 115 |
# Get color scheme |
|
| 116 | 666x |
palette <- color(scheme, reverse = reverse, names = FALSE, lang = lang) |
| 117 | 666x |
max <- attr(palette, "max") |
| 118 | 666x |
type <- attr(palette, "type") |
| 119 | ||
| 120 |
# Build scale |
|
| 121 | 666x |
scale_args <- list(...) |
| 122 | 666x |
scale_args$guide <- guide |
| 123 | 666x |
scale_args$na.value <- scale_args$na.value %||% attr(palette, "missing") |
| 124 | ||
| 125 | 666x |
if (type == "diverging") {
|
| 126 | 320x |
scale_args$rescaler <- rescale_mid(mid = midpoint) |
| 127 |
} |
|
| 128 | ||
| 129 | 666x |
palette <- scales::gradient_n_pal(palette(max, range = range)) |
| 130 | 666x |
do.call( |
| 131 | 666x |
ggplot2::continuous_scale, |
| 132 | 666x |
c(aesthetics = aesthetics, palette = palette, scale_args) |
| 133 |
) |
|
| 134 |
} |
|
| 135 | ||
| 136 |
rescale_mid <- function(mid) {
|
|
| 137 | 320x |
function(x, to = c(0, 1), from = range(x, na.rm = TRUE)) {
|
| 138 | ! |
scale_midpoint(x, to = to, from = from, midpoint = mid) |
| 139 |
} |
|
| 140 |
} |
| 1 |
# Fabio Crameri's color schemes |
|
| 2 |
#' @include color.R |
|
| 3 |
NULL |
|
| 4 | ||
| 5 |
# Diverging ==================================================================== |
|
| 6 |
## broc ------------------------------------------------------------------------ |
|
| 7 |
#' Fabio Crameri's *broc* Diverging Color Scheme |
|
| 8 |
#' |
|
| 9 |
#' @param ... Arguments passed to [ggplot2::continuous_scale()]. |
|
| 10 |
#' @param reverse A [`logical`] scalar. Should the resulting |
|
| 11 |
#' vector of colors be reversed? |
|
| 12 |
#' @param range A length-two [`numeric`] vector specifying the |
|
| 13 |
#' fraction of the scheme's color domain to keep. |
|
| 14 |
#' @param midpoint A length-one [`numeric`] vector giving the midpoint |
|
| 15 |
#' (in data value) of the diverging scale. Defaults to `0`. |
|
| 16 |
#' @param aesthetics A [`character`] string or vector of character |
|
| 17 |
#' strings listing the name(s) of the aesthetic(s) that this scale works with. |
|
| 18 |
#' @param discrete A [`logical`] scalar: should the color scheme be |
|
| 19 |
#' used as a discrete scale? |
|
| 20 |
#' @inheritSection crameri Diverging Color Schemes |
|
| 21 |
#' @return A [continuous][ggplot2::continuous_scale] scale. |
|
| 22 |
#' @references |
|
| 23 |
#' Crameri, F. (2018). Geodynamic diagnostics, scientific visualisation and |
|
| 24 |
#' StagLab 3.0. *Geosci. Model Dev.*, 11, 2541-2562. |
|
| 25 |
#' \doi{10.5194/gmd-11-2541-2018}
|
|
| 26 |
#' |
|
| 27 |
#' Crameri, F., Shephard, G. E. & Heron, P. J. (2020). The misuse of colour in |
|
| 28 |
#' science communication. *Nature Communications*, 11, 5444. |
|
| 29 |
#' \doi{10.1038/s41467-020-19160-7}
|
|
| 30 |
#' @source |
|
| 31 |
#' Crameri, F. (2023). Scientific colour maps. *Zenodo*, v8.0.1. |
|
| 32 |
#' \doi{10.5281/zenodo.1243862}
|
|
| 33 |
#' @example inst/examples/ex-crameri-diverging.R |
|
| 34 |
#' @author N. Frerebeau |
|
| 35 |
#' @family diverging color schemes |
|
| 36 |
#' @family Fabio Crameri's color schemes |
|
| 37 |
#' @name scale_crameri_broc |
|
| 38 |
#' @rdname scale_crameri_broc |
|
| 39 |
NULL |
|
| 40 | ||
| 41 |
#' @export |
|
| 42 |
#' @rdname scale_crameri_broc |
|
| 43 |
scale_colour_broc <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 44 |
midpoint = 0, discrete = FALSE, |
|
| 45 |
aesthetics = "colour") {
|
|
| 46 | 6x |
if (discrete) {
|
| 47 | ! |
scale_discrete(aesthetics, "broc", reverse = reverse, ...) |
| 48 |
} else {
|
|
| 49 | 6x |
scale_continuous(aesthetics, "broc", reverse = reverse, range = range, |
| 50 | 6x |
midpoint = midpoint, ...) |
| 51 |
} |
|
| 52 |
} |
|
| 53 | ||
| 54 |
#' @export |
|
| 55 |
#' @rdname scale_crameri_broc |
|
| 56 |
scale_color_broc <- scale_colour_broc |
|
| 57 | ||
| 58 |
#' @export |
|
| 59 |
#' @rdname scale_crameri_broc |
|
| 60 |
scale_fill_broc <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 61 |
midpoint = 0, discrete = FALSE, |
|
| 62 |
aesthetics = "fill") {
|
|
| 63 | 4x |
if (discrete) {
|
| 64 | ! |
scale_discrete(aesthetics, "broc", reverse = reverse, ...) |
| 65 |
} else {
|
|
| 66 | 4x |
scale_continuous(aesthetics, "broc", reverse = reverse, range = range, |
| 67 | 4x |
midpoint = midpoint, ...) |
| 68 |
} |
|
| 69 |
} |
|
| 70 | ||
| 71 |
#' @export |
|
| 72 |
#' @rdname scale_crameri_broc |
|
| 73 |
scale_edge_colour_broc <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 74 |
midpoint = 0, discrete = FALSE, |
|
| 75 |
aesthetics = "edge_colour") {
|
|
| 76 | 6x |
if (discrete) {
|
| 77 | ! |
scale_discrete(aesthetics, "broc", reverse = reverse, ...) |
| 78 |
} else {
|
|
| 79 | 6x |
scale_continuous(aesthetics, "broc", guide = "edge_colourbar", |
| 80 | 6x |
reverse = reverse, range = range, midpoint = midpoint, ...) |
| 81 |
} |
|
| 82 |
} |
|
| 83 | ||
| 84 |
#' @export |
|
| 85 |
#' @rdname scale_crameri_broc |
|
| 86 |
scale_edge_color_broc <- scale_edge_colour_broc |
|
| 87 | ||
| 88 |
#' @export |
|
| 89 |
#' @rdname scale_crameri_broc |
|
| 90 |
scale_edge_fill_broc <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 91 |
midpoint = 0, discrete = FALSE, |
|
| 92 |
aesthetics = "edge_fill") {
|
|
| 93 | 4x |
if (discrete) {
|
| 94 | ! |
scale_discrete(aesthetics, "broc", reverse = reverse, ...) |
| 95 |
} else {
|
|
| 96 | 4x |
scale_continuous(aesthetics, "broc", guide = "edge_colourbar", |
| 97 | 4x |
reverse = reverse, range = range, midpoint = midpoint, ...) |
| 98 |
} |
|
| 99 |
} |
|
| 100 | ||
| 101 |
## cork ------------------------------------------------------------------------ |
|
| 102 |
#' Fabio Crameri's *cork* Diverging Color Scheme |
|
| 103 |
#' |
|
| 104 |
#' @inheritParams scale_crameri_broc |
|
| 105 |
#' @inheritSection crameri Diverging Color Schemes |
|
| 106 |
#' @return A [continuous][ggplot2::continuous_scale] scale. |
|
| 107 |
#' @references |
|
| 108 |
#' Crameri, F. (2018). Geodynamic diagnostics, scientific visualisation and |
|
| 109 |
#' StagLab 3.0. *Geosci. Model Dev.*, 11, 2541-2562. |
|
| 110 |
#' \doi{10.5194/gmd-11-2541-2018}
|
|
| 111 |
#' |
|
| 112 |
#' Crameri, F., Shephard, G. E. & Heron, P. J. (2020). The misuse of colour in |
|
| 113 |
#' science communication. *Nature Communications*, 11, 5444. |
|
| 114 |
#' \doi{10.1038/s41467-020-19160-7}
|
|
| 115 |
#' @source |
|
| 116 |
#' Crameri, F. (2023). Scientific colour maps. *Zenodo*, v8.0.1. |
|
| 117 |
#' \doi{10.5281/zenodo.1243862}
|
|
| 118 |
#' @example inst/examples/ex-crameri-diverging.R |
|
| 119 |
#' @author N. Frerebeau |
|
| 120 |
#' @family diverging color schemes |
|
| 121 |
#' @family Fabio Crameri's color schemes |
|
| 122 |
#' @name scale_crameri_cork |
|
| 123 |
#' @rdname scale_crameri_cork |
|
| 124 |
NULL |
|
| 125 | ||
| 126 |
#' @export |
|
| 127 |
#' @rdname scale_crameri_cork |
|
| 128 |
scale_colour_cork <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 129 |
midpoint = 0, discrete = FALSE, |
|
| 130 |
aesthetics = "colour") {
|
|
| 131 | 6x |
if (discrete) {
|
| 132 | ! |
scale_discrete(aesthetics, "cork", reverse = reverse, ...) |
| 133 |
} else {
|
|
| 134 | 6x |
scale_continuous(aesthetics, "cork", reverse = reverse, range = range, |
| 135 | 6x |
midpoint = midpoint, ...) |
| 136 |
} |
|
| 137 |
} |
|
| 138 | ||
| 139 |
#' @export |
|
| 140 |
#' @rdname scale_crameri_cork |
|
| 141 |
scale_color_cork <- scale_colour_cork |
|
| 142 | ||
| 143 |
#' @export |
|
| 144 |
#' @rdname scale_crameri_cork |
|
| 145 |
scale_fill_cork <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 146 |
midpoint = 0, discrete = FALSE, |
|
| 147 |
aesthetics = "fill") {
|
|
| 148 | 4x |
if (discrete) {
|
| 149 | ! |
scale_discrete(aesthetics, "cork", reverse = reverse, ...) |
| 150 |
} else {
|
|
| 151 | 4x |
scale_continuous(aesthetics, "cork", reverse = reverse, range = range, |
| 152 | 4x |
midpoint = midpoint, ...) |
| 153 |
} |
|
| 154 |
} |
|
| 155 | ||
| 156 |
#' @export |
|
| 157 |
#' @rdname scale_crameri_cork |
|
| 158 |
scale_edge_colour_cork <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 159 |
midpoint = 0, discrete = FALSE, |
|
| 160 |
aesthetics = "edge_colour") {
|
|
| 161 | 6x |
if (discrete) {
|
| 162 | ! |
scale_discrete(aesthetics, "cork", reverse = reverse, ...) |
| 163 |
} else {
|
|
| 164 | 6x |
scale_continuous(aesthetics, "cork", guide = "edge_colourbar", |
| 165 | 6x |
reverse = reverse, range = range, midpoint = midpoint, ...) |
| 166 |
} |
|
| 167 |
} |
|
| 168 | ||
| 169 |
#' @export |
|
| 170 |
#' @rdname scale_crameri_cork |
|
| 171 |
scale_edge_color_cork <- scale_edge_colour_cork |
|
| 172 | ||
| 173 |
#' @export |
|
| 174 |
#' @rdname scale_crameri_cork |
|
| 175 |
scale_edge_fill_cork <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 176 |
midpoint = 0, discrete = FALSE, |
|
| 177 |
aesthetics = "edge_fill") {
|
|
| 178 | 4x |
if (discrete) {
|
| 179 | ! |
scale_discrete(aesthetics, "cork", reverse = reverse, ...) |
| 180 |
} else {
|
|
| 181 | 4x |
scale_continuous(aesthetics, "cork", guide = "edge_colourbar", |
| 182 | 4x |
reverse = reverse, range = range, midpoint = midpoint, ...) |
| 183 |
} |
|
| 184 |
} |
|
| 185 | ||
| 186 |
## vik ------------------------------------------------------------------------- |
|
| 187 |
#' Fabio Crameri's *vik* Diverging Color Scheme |
|
| 188 |
#' |
|
| 189 |
#' @inheritParams scale_crameri_broc |
|
| 190 |
#' @inheritSection crameri Diverging Color Schemes |
|
| 191 |
#' @return A [continuous][ggplot2::continuous_scale] scale. |
|
| 192 |
#' @references |
|
| 193 |
#' Crameri, F. (2018). Geodynamic diagnostics, scientific visualisation and |
|
| 194 |
#' StagLab 3.0. *Geosci. Model Dev.*, 11, 2541-2562. |
|
| 195 |
#' \doi{10.5194/gmd-11-2541-2018}
|
|
| 196 |
#' |
|
| 197 |
#' Crameri, F., Shephard, G. E. & Heron, P. J. (2020). The misuse of colour in |
|
| 198 |
#' science communication. *Nature Communications*, 11, 5444. |
|
| 199 |
#' \doi{10.1038/s41467-020-19160-7}
|
|
| 200 |
#' @source |
|
| 201 |
#' Crameri, F. (2023). Scientific colour maps. *Zenodo*, v8.0.1. |
|
| 202 |
#' \doi{10.5281/zenodo.1243862}
|
|
| 203 |
#' @example inst/examples/ex-crameri-diverging.R |
|
| 204 |
#' @author N. Frerebeau |
|
| 205 |
#' @family diverging color schemes |
|
| 206 |
#' @family Fabio Crameri's color schemes |
|
| 207 |
#' @name scale_crameri_vik |
|
| 208 |
#' @rdname scale_crameri_vik |
|
| 209 |
NULL |
|
| 210 | ||
| 211 |
#' @export |
|
| 212 |
#' @rdname scale_crameri_vik |
|
| 213 |
scale_colour_vik <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 214 |
midpoint = 0, discrete = FALSE, |
|
| 215 |
aesthetics = "colour") {
|
|
| 216 | 6x |
if (discrete) {
|
| 217 | ! |
scale_discrete(aesthetics, "vik", reverse = reverse, ...) |
| 218 |
} else {
|
|
| 219 | 6x |
scale_continuous(aesthetics, "vik", reverse = reverse, range = range, |
| 220 | 6x |
midpoint = midpoint, ...) |
| 221 |
} |
|
| 222 |
} |
|
| 223 | ||
| 224 |
#' @export |
|
| 225 |
#' @rdname scale_crameri_vik |
|
| 226 |
scale_color_vik <- scale_colour_vik |
|
| 227 | ||
| 228 |
#' @export |
|
| 229 |
#' @rdname scale_crameri_vik |
|
| 230 |
scale_fill_vik <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 231 |
midpoint = 0, discrete = FALSE, |
|
| 232 |
aesthetics = "fill") {
|
|
| 233 | 4x |
if (discrete) {
|
| 234 | ! |
scale_discrete(aesthetics, "vik", reverse = reverse, ...) |
| 235 |
} else {
|
|
| 236 | 4x |
scale_continuous(aesthetics, "vik", reverse = reverse, range = range, |
| 237 | 4x |
midpoint = midpoint, ...) |
| 238 |
} |
|
| 239 |
} |
|
| 240 | ||
| 241 |
#' @export |
|
| 242 |
#' @rdname scale_crameri_vik |
|
| 243 |
scale_edge_colour_vik <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 244 |
midpoint = 0, discrete = FALSE, |
|
| 245 |
aesthetics = "edge_colour") {
|
|
| 246 | 6x |
if (discrete) {
|
| 247 | ! |
scale_discrete(aesthetics, "vik", reverse = reverse, ...) |
| 248 |
} else {
|
|
| 249 | 6x |
scale_continuous(aesthetics, "vik", guide = "edge_colourbar", |
| 250 | 6x |
reverse = reverse, range = range, midpoint = midpoint, ...) |
| 251 |
} |
|
| 252 |
} |
|
| 253 | ||
| 254 |
#' @export |
|
| 255 |
#' @rdname scale_crameri_vik |
|
| 256 |
scale_edge_color_vik <- scale_edge_colour_vik |
|
| 257 | ||
| 258 |
#' @export |
|
| 259 |
#' @rdname scale_crameri_vik |
|
| 260 |
scale_edge_fill_vik <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 261 |
midpoint = 0, discrete = FALSE, |
|
| 262 |
aesthetics = "edge_fill") {
|
|
| 263 | 4x |
if (discrete) {
|
| 264 | ! |
scale_discrete(aesthetics, "vik", reverse = reverse, ...) |
| 265 |
} else {
|
|
| 266 | 4x |
scale_continuous(aesthetics, "vik", guide = "edge_colourbar", |
| 267 | 4x |
reverse = reverse, range = range, midpoint = midpoint, ...) |
| 268 |
} |
|
| 269 |
} |
|
| 270 | ||
| 271 |
## lisbon ---------------------------------------------------------------------- |
|
| 272 |
#' Fabio Crameri's *lisbon* Diverging Color Scheme |
|
| 273 |
#' |
|
| 274 |
#' @inheritParams scale_crameri_broc |
|
| 275 |
#' @inheritSection crameri Diverging Color Schemes |
|
| 276 |
#' @return A [continuous][ggplot2::continuous_scale] scale. |
|
| 277 |
#' @references |
|
| 278 |
#' Crameri, F. (2018). Geodynamic diagnostics, scientific visualisation and |
|
| 279 |
#' StagLab 3.0. *Geosci. Model Dev.*, 11, 2541-2562. |
|
| 280 |
#' \doi{10.5194/gmd-11-2541-2018}
|
|
| 281 |
#' |
|
| 282 |
#' Crameri, F., Shephard, G. E. & Heron, P. J. (2020). The misuse of colour in |
|
| 283 |
#' science communication. *Nature Communications*, 11, 5444. |
|
| 284 |
#' \doi{10.1038/s41467-020-19160-7}
|
|
| 285 |
#' @source |
|
| 286 |
#' Crameri, F. (2023). Scientific colour maps. *Zenodo*, v8.0.1. |
|
| 287 |
#' \doi{10.5281/zenodo.1243862}
|
|
| 288 |
#' @example inst/examples/ex-crameri-diverging.R |
|
| 289 |
#' @author N. Frerebeau |
|
| 290 |
#' @family diverging color schemes |
|
| 291 |
#' @family Fabio Crameri's color schemes |
|
| 292 |
#' @name scale_crameri_lisbon |
|
| 293 |
#' @rdname scale_crameri_lisbon |
|
| 294 |
NULL |
|
| 295 | ||
| 296 |
#' @export |
|
| 297 |
#' @rdname scale_crameri_lisbon |
|
| 298 |
scale_colour_lisbon <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 299 |
midpoint = 0, discrete = FALSE, |
|
| 300 |
aesthetics = "colour") {
|
|
| 301 | 6x |
if (discrete) {
|
| 302 | ! |
scale_discrete(aesthetics, "lisbon", reverse = reverse, ...) |
| 303 |
} else {
|
|
| 304 | 6x |
scale_continuous(aesthetics, "lisbon", reverse = reverse, range = range, |
| 305 | 6x |
midpoint = midpoint, ...) |
| 306 |
} |
|
| 307 |
} |
|
| 308 | ||
| 309 |
#' @export |
|
| 310 |
#' @rdname scale_crameri_lisbon |
|
| 311 |
scale_color_lisbon <- scale_colour_lisbon |
|
| 312 | ||
| 313 |
#' @export |
|
| 314 |
#' @rdname scale_crameri_lisbon |
|
| 315 |
scale_fill_lisbon <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 316 |
midpoint = 0, discrete = FALSE, |
|
| 317 |
aesthetics = "fill") {
|
|
| 318 | 4x |
if (discrete) {
|
| 319 | ! |
scale_discrete(aesthetics, "lisbon", reverse = reverse, ...) |
| 320 |
} else {
|
|
| 321 | 4x |
scale_continuous(aesthetics, "lisbon", reverse = reverse, range = range, |
| 322 | 4x |
midpoint = midpoint, ...) |
| 323 |
} |
|
| 324 |
} |
|
| 325 | ||
| 326 |
#' @export |
|
| 327 |
#' @rdname scale_crameri_lisbon |
|
| 328 |
scale_edge_colour_lisbon <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 329 |
midpoint = 0, discrete = FALSE, |
|
| 330 |
aesthetics = "edge_colour") {
|
|
| 331 | 6x |
if (discrete) {
|
| 332 | ! |
scale_discrete(aesthetics, "lisbon", reverse = reverse, ...) |
| 333 |
} else {
|
|
| 334 | 6x |
scale_continuous(aesthetics, "lisbon", guide = "edge_colourbar", |
| 335 | 6x |
reverse = reverse, range = range, midpoint = midpoint, ...) |
| 336 |
} |
|
| 337 |
} |
|
| 338 | ||
| 339 |
#' @export |
|
| 340 |
#' @rdname scale_crameri_lisbon |
|
| 341 |
scale_edge_color_lisbon <- scale_edge_colour_lisbon |
|
| 342 | ||
| 343 |
#' @export |
|
| 344 |
#' @rdname scale_crameri_lisbon |
|
| 345 |
scale_edge_fill_lisbon <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 346 |
midpoint = 0, discrete = FALSE, |
|
| 347 |
aesthetics = "edge_fill") {
|
|
| 348 | 4x |
if (discrete) {
|
| 349 | ! |
scale_discrete(aesthetics, "lisbon", reverse = reverse, ...) |
| 350 |
} else {
|
|
| 351 | 4x |
scale_continuous(aesthetics, "lisbon", guide = "edge_colourbar", |
| 352 | 4x |
reverse = reverse, range = range, midpoint = midpoint, ...) |
| 353 |
} |
|
| 354 |
} |
|
| 355 | ||
| 356 |
## tofino ---------------------------------------------------------------------- |
|
| 357 |
#' Fabio Crameri's *tofino* Diverging Color Scheme |
|
| 358 |
#' |
|
| 359 |
#' @inheritParams scale_crameri_broc |
|
| 360 |
#' @inheritSection crameri Diverging Color Schemes |
|
| 361 |
#' @return A [continuous][ggplot2::continuous_scale] scale. |
|
| 362 |
#' @references |
|
| 363 |
#' Crameri, F. (2018). Geodynamic diagnostics, scientific visualisation and |
|
| 364 |
#' StagLab 3.0. *Geosci. Model Dev.*, 11, 2541-2562. |
|
| 365 |
#' \doi{10.5194/gmd-11-2541-2018}
|
|
| 366 |
#' |
|
| 367 |
#' Crameri, F., Shephard, G. E. & Heron, P. J. (2020). The misuse of colour in |
|
| 368 |
#' science communication. *Nature Communications*, 11, 5444. |
|
| 369 |
#' \doi{10.1038/s41467-020-19160-7}
|
|
| 370 |
#' @source |
|
| 371 |
#' Crameri, F. (2023). Scientific colour maps. *Zenodo*, v8.0.1. |
|
| 372 |
#' \doi{10.5281/zenodo.1243862}
|
|
| 373 |
#' @example inst/examples/ex-crameri-diverging.R |
|
| 374 |
#' @author N. Frerebeau |
|
| 375 |
#' @family diverging color schemes |
|
| 376 |
#' @family Fabio Crameri's color schemes |
|
| 377 |
#' @name scale_crameri_tofino |
|
| 378 |
#' @rdname scale_crameri_tofino |
|
| 379 |
NULL |
|
| 380 | ||
| 381 |
#' @export |
|
| 382 |
#' @rdname scale_crameri_tofino |
|
| 383 |
scale_colour_tofino <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 384 |
midpoint = 0, discrete = FALSE, |
|
| 385 |
aesthetics = "colour") {
|
|
| 386 | 6x |
if (discrete) {
|
| 387 | ! |
scale_discrete(aesthetics, "tofino", reverse = reverse, ...) |
| 388 |
} else {
|
|
| 389 | 6x |
scale_continuous(aesthetics, "tofino", reverse = reverse, range = range, |
| 390 | 6x |
midpoint = midpoint, ...) |
| 391 |
} |
|
| 392 |
} |
|
| 393 | ||
| 394 |
#' @export |
|
| 395 |
#' @rdname scale_crameri_tofino |
|
| 396 |
scale_color_tofino <- scale_colour_tofino |
|
| 397 | ||
| 398 |
#' @export |
|
| 399 |
#' @rdname scale_crameri_tofino |
|
| 400 |
scale_fill_tofino <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 401 |
midpoint = 0, discrete = FALSE, |
|
| 402 |
aesthetics = "fill") {
|
|
| 403 | 4x |
if (discrete) {
|
| 404 | ! |
scale_discrete(aesthetics, "tofino", reverse = reverse, ...) |
| 405 |
} else {
|
|
| 406 | 4x |
scale_continuous(aesthetics, "tofino", reverse = reverse, range = range, |
| 407 | 4x |
midpoint = midpoint, ...) |
| 408 |
} |
|
| 409 |
} |
|
| 410 | ||
| 411 |
#' @export |
|
| 412 |
#' @rdname scale_crameri_tofino |
|
| 413 |
scale_edge_colour_tofino <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 414 |
midpoint = 0, discrete = FALSE, |
|
| 415 |
aesthetics = "edge_colour") {
|
|
| 416 | 6x |
if (discrete) {
|
| 417 | ! |
scale_discrete(aesthetics, "tofino", reverse = reverse, ...) |
| 418 |
} else {
|
|
| 419 | 6x |
scale_continuous(aesthetics, "tofino", guide = "edge_colourbar", |
| 420 | 6x |
reverse = reverse, range = range, midpoint = midpoint, ...) |
| 421 |
} |
|
| 422 |
} |
|
| 423 | ||
| 424 |
#' @export |
|
| 425 |
#' @rdname scale_crameri_tofino |
|
| 426 |
scale_edge_color_tofino <- scale_edge_colour_tofino |
|
| 427 | ||
| 428 |
#' @export |
|
| 429 |
#' @rdname scale_crameri_tofino |
|
| 430 |
scale_edge_fill_tofino <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 431 |
midpoint = 0, discrete = FALSE, |
|
| 432 |
aesthetics = "edge_fill") {
|
|
| 433 | 4x |
if (discrete) {
|
| 434 | ! |
scale_discrete(aesthetics, "tofino", reverse = reverse, ...) |
| 435 |
} else {
|
|
| 436 | 4x |
scale_continuous(aesthetics, "tofino", guide = "edge_colourbar", |
| 437 | 4x |
reverse = reverse, range = range, midpoint = midpoint, ...) |
| 438 |
} |
|
| 439 |
} |
|
| 440 | ||
| 441 |
## berlin ---------------------------------------------------------------------- |
|
| 442 |
#' Fabio Crameri's *berlin* Diverging Color Scheme |
|
| 443 |
#' |
|
| 444 |
#' @inheritParams scale_crameri_broc |
|
| 445 |
#' @inheritSection crameri Diverging Color Schemes |
|
| 446 |
#' @return A [continuous][ggplot2::continuous_scale] scale. |
|
| 447 |
#' @references |
|
| 448 |
#' Crameri, F. (2018). Geodynamic diagnostics, scientific visualisation and |
|
| 449 |
#' StagLab 3.0. *Geosci. Model Dev.*, 11, 2541-2562. |
|
| 450 |
#' \doi{10.5194/gmd-11-2541-2018}
|
|
| 451 |
#' |
|
| 452 |
#' Crameri, F., Shephard, G. E. & Heron, P. J. (2020). The misuse of colour in |
|
| 453 |
#' science communication. *Nature Communications*, 11, 5444. |
|
| 454 |
#' \doi{10.1038/s41467-020-19160-7}
|
|
| 455 |
#' @source |
|
| 456 |
#' Crameri, F. (2023). Scientific colour maps. *Zenodo*, v8.0.1. |
|
| 457 |
#' \doi{10.5281/zenodo.1243862}
|
|
| 458 |
#' @example inst/examples/ex-crameri-diverging.R |
|
| 459 |
#' @author N. Frerebeau |
|
| 460 |
#' @family diverging color schemes |
|
| 461 |
#' @family Fabio Crameri's color schemes |
|
| 462 |
#' @name scale_crameri_berlin |
|
| 463 |
#' @rdname scale_crameri_berlin |
|
| 464 |
NULL |
|
| 465 | ||
| 466 |
#' @export |
|
| 467 |
#' @rdname scale_crameri_berlin |
|
| 468 |
scale_colour_berlin <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 469 |
midpoint = 0, discrete = FALSE, |
|
| 470 |
aesthetics = "colour") {
|
|
| 471 | 6x |
if (discrete) {
|
| 472 | ! |
scale_discrete(aesthetics, "berlin", reverse = reverse, ...) |
| 473 |
} else {
|
|
| 474 | 6x |
scale_continuous(aesthetics, "berlin", reverse = reverse, range = range, |
| 475 | 6x |
midpoint = midpoint, ...) |
| 476 |
} |
|
| 477 |
} |
|
| 478 | ||
| 479 |
#' @export |
|
| 480 |
#' @rdname scale_crameri_berlin |
|
| 481 |
scale_color_berlin <- scale_colour_berlin |
|
| 482 | ||
| 483 |
#' @export |
|
| 484 |
#' @rdname scale_crameri_berlin |
|
| 485 |
scale_fill_berlin <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 486 |
midpoint = 0, discrete = FALSE, |
|
| 487 |
aesthetics = "fill") {
|
|
| 488 | 4x |
if (discrete) {
|
| 489 | ! |
scale_discrete(aesthetics, "berlin", reverse = reverse, ...) |
| 490 |
} else {
|
|
| 491 | 4x |
scale_continuous(aesthetics, "berlin", reverse = reverse, range = range, |
| 492 | 4x |
midpoint = midpoint, ...) |
| 493 |
} |
|
| 494 |
} |
|
| 495 | ||
| 496 |
#' @export |
|
| 497 |
#' @rdname scale_crameri_berlin |
|
| 498 |
scale_edge_colour_berlin <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 499 |
midpoint = 0, discrete = FALSE, |
|
| 500 |
aesthetics = "edge_colour") {
|
|
| 501 | 6x |
if (discrete) {
|
| 502 | ! |
scale_discrete(aesthetics, "berlin", reverse = reverse, ...) |
| 503 |
} else {
|
|
| 504 | 6x |
scale_continuous(aesthetics, "berlin", guide = "edge_colourbar", |
| 505 | 6x |
reverse = reverse, range = range, midpoint = midpoint, ...) |
| 506 |
} |
|
| 507 |
} |
|
| 508 | ||
| 509 |
#' @export |
|
| 510 |
#' @rdname scale_crameri_berlin |
|
| 511 |
scale_edge_color_berlin <- scale_edge_colour_berlin |
|
| 512 | ||
| 513 |
#' @export |
|
| 514 |
#' @rdname scale_crameri_berlin |
|
| 515 |
scale_edge_fill_berlin <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 516 |
midpoint = 0, discrete = FALSE, |
|
| 517 |
aesthetics = "edge_fill") {
|
|
| 518 | 4x |
if (discrete) {
|
| 519 | ! |
scale_discrete(aesthetics, "berlin", reverse = reverse, ...) |
| 520 |
} else {
|
|
| 521 | 4x |
scale_continuous(aesthetics, "berlin", guide = "edge_colourbar", |
| 522 | 4x |
reverse = reverse, range = range, midpoint = midpoint, ...) |
| 523 |
} |
|
| 524 |
} |
|
| 525 | ||
| 526 |
## roma ------------------------------------------------------------------------ |
|
| 527 |
#' Fabio Crameri's *roma* Diverging Color Scheme |
|
| 528 |
#' |
|
| 529 |
#' @inheritParams scale_crameri_broc |
|
| 530 |
#' @inheritSection crameri Diverging Color Schemes |
|
| 531 |
#' @return A [continuous][ggplot2::continuous_scale] scale. |
|
| 532 |
#' @references |
|
| 533 |
#' Crameri, F. (2018). Geodynamic diagnostics, scientific visualisation and |
|
| 534 |
#' StagLab 3.0. *Geosci. Model Dev.*, 11, 2541-2562. |
|
| 535 |
#' \doi{10.5194/gmd-11-2541-2018}
|
|
| 536 |
#' |
|
| 537 |
#' Crameri, F., Shephard, G. E. & Heron, P. J. (2020). The misuse of colour in |
|
| 538 |
#' science communication. *Nature Communications*, 11, 5444. |
|
| 539 |
#' \doi{10.1038/s41467-020-19160-7}
|
|
| 540 |
#' @source |
|
| 541 |
#' Crameri, F. (2023). Scientific colour maps. *Zenodo*, v8.0.1. |
|
| 542 |
#' \doi{10.5281/zenodo.1243862}
|
|
| 543 |
#' @example inst/examples/ex-crameri-diverging.R |
|
| 544 |
#' @author N. Frerebeau |
|
| 545 |
#' @family diverging color schemes |
|
| 546 |
#' @family Fabio Crameri's color schemes |
|
| 547 |
#' @name scale_crameri_roma |
|
| 548 |
#' @rdname scale_crameri_roma |
|
| 549 |
NULL |
|
| 550 | ||
| 551 |
#' @export |
|
| 552 |
#' @rdname scale_crameri_roma |
|
| 553 |
scale_colour_roma <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 554 |
midpoint = 0, discrete = FALSE, |
|
| 555 |
aesthetics = "colour") {
|
|
| 556 | 6x |
if (discrete) {
|
| 557 | ! |
scale_discrete(aesthetics, "roma", reverse = reverse, ...) |
| 558 |
} else {
|
|
| 559 | 6x |
scale_continuous(aesthetics, "roma", reverse = reverse, range = range, |
| 560 | 6x |
midpoint = midpoint, ...) |
| 561 |
} |
|
| 562 |
} |
|
| 563 | ||
| 564 |
#' @export |
|
| 565 |
#' @rdname scale_crameri_roma |
|
| 566 |
scale_color_roma <- scale_colour_roma |
|
| 567 | ||
| 568 |
#' @export |
|
| 569 |
#' @rdname scale_crameri_roma |
|
| 570 |
scale_fill_roma <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 571 |
midpoint = 0, discrete = FALSE, |
|
| 572 |
aesthetics = "fill") {
|
|
| 573 | 4x |
if (discrete) {
|
| 574 | ! |
scale_discrete(aesthetics, "roma", reverse = reverse, ...) |
| 575 |
} else {
|
|
| 576 | 4x |
scale_continuous(aesthetics, "roma", reverse = reverse, range = range, |
| 577 | 4x |
midpoint = midpoint, ...) |
| 578 |
} |
|
| 579 |
} |
|
| 580 | ||
| 581 |
#' @export |
|
| 582 |
#' @rdname scale_crameri_roma |
|
| 583 |
scale_edge_colour_roma <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 584 |
midpoint = 0, discrete = FALSE, |
|
| 585 |
aesthetics = "edge_colour") {
|
|
| 586 | 6x |
if (discrete) {
|
| 587 | ! |
scale_discrete(aesthetics, "roma", reverse = reverse, ...) |
| 588 |
} else {
|
|
| 589 | 6x |
scale_continuous(aesthetics, "roma", guide = "edge_colourbar", |
| 590 | 6x |
reverse = reverse, range = range, midpoint = midpoint, ...) |
| 591 |
} |
|
| 592 |
} |
|
| 593 | ||
| 594 |
#' @export |
|
| 595 |
#' @rdname scale_crameri_roma |
|
| 596 |
scale_edge_color_roma <- scale_edge_colour_roma |
|
| 597 | ||
| 598 |
#' @export |
|
| 599 |
#' @rdname scale_crameri_roma |
|
| 600 |
scale_edge_fill_roma <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 601 |
midpoint = 0, discrete = FALSE, |
|
| 602 |
aesthetics = "edge_fill") {
|
|
| 603 | 4x |
if (discrete) {
|
| 604 | ! |
scale_discrete(aesthetics, "roma", reverse = reverse, ...) |
| 605 |
} else {
|
|
| 606 | 4x |
scale_continuous(aesthetics, "roma", guide = "edge_colourbar", |
| 607 | 4x |
reverse = reverse, range = range, midpoint = midpoint, ...) |
| 608 |
} |
|
| 609 |
} |
|
| 610 | ||
| 611 |
## bam ------------------------------------------------------------------------- |
|
| 612 |
#' Fabio Crameri's *bam* Diverging Color Scheme |
|
| 613 |
#' |
|
| 614 |
#' @inheritParams scale_crameri_broc |
|
| 615 |
#' @inheritSection crameri Diverging Color Schemes |
|
| 616 |
#' @return A [continuous][ggplot2::continuous_scale] scale. |
|
| 617 |
#' @references |
|
| 618 |
#' Crameri, F. (2018). Geodynamic diagnostics, scientific visualisation and |
|
| 619 |
#' StagLab 3.0. *Geosci. Model Dev.*, 11, 2541-2562. |
|
| 620 |
#' \doi{10.5194/gmd-11-2541-2018}
|
|
| 621 |
#' |
|
| 622 |
#' Crameri, F., Shephard, G. E. & Heron, P. J. (2020). The misuse of colour in |
|
| 623 |
#' science communication. *Nature Communications*, 11, 5444. |
|
| 624 |
#' \doi{10.1038/s41467-020-19160-7}
|
|
| 625 |
#' @source |
|
| 626 |
#' Crameri, F. (2023). Scientific colour maps. *Zenodo*, v8.0.1. |
|
| 627 |
#' \doi{10.5281/zenodo.1243862}
|
|
| 628 |
#' @example inst/examples/ex-crameri-diverging.R |
|
| 629 |
#' @author N. Frerebeau |
|
| 630 |
#' @family diverging color schemes |
|
| 631 |
#' @family Fabio Crameri's color schemes |
|
| 632 |
#' @name scale_crameri_bam |
|
| 633 |
#' @rdname scale_crameri_bam |
|
| 634 |
NULL |
|
| 635 | ||
| 636 |
#' @export |
|
| 637 |
#' @rdname scale_crameri_bam |
|
| 638 |
scale_colour_bam <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 639 |
midpoint = 0, discrete = FALSE, |
|
| 640 |
aesthetics = "colour") {
|
|
| 641 | 6x |
if (discrete) {
|
| 642 | ! |
scale_discrete(aesthetics, "bam", reverse = reverse, ...) |
| 643 |
} else {
|
|
| 644 | 6x |
scale_continuous(aesthetics, "bam", reverse = reverse, range = range, |
| 645 | 6x |
midpoint = midpoint, ...) |
| 646 |
} |
|
| 647 |
} |
|
| 648 | ||
| 649 |
#' @export |
|
| 650 |
#' @rdname scale_crameri_bam |
|
| 651 |
scale_color_bam <- scale_colour_bam |
|
| 652 | ||
| 653 |
#' @export |
|
| 654 |
#' @rdname scale_crameri_bam |
|
| 655 |
scale_fill_bam <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 656 |
midpoint = 0, discrete = FALSE, |
|
| 657 |
aesthetics = "fill") {
|
|
| 658 | 4x |
if (discrete) {
|
| 659 | ! |
scale_discrete(aesthetics, "bam", reverse = reverse, ...) |
| 660 |
} else {
|
|
| 661 | 4x |
scale_continuous(aesthetics, "bam", reverse = reverse, range = range, |
| 662 | 4x |
midpoint = midpoint, ...) |
| 663 |
} |
|
| 664 |
} |
|
| 665 | ||
| 666 |
#' @export |
|
| 667 |
#' @rdname scale_crameri_bam |
|
| 668 |
scale_edge_colour_bam <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 669 |
midpoint = 0, discrete = FALSE, |
|
| 670 |
aesthetics = "edge_colour") {
|
|
| 671 | 6x |
if (discrete) {
|
| 672 | ! |
scale_discrete(aesthetics, "bam", reverse = reverse, ...) |
| 673 |
} else {
|
|
| 674 | 6x |
scale_continuous(aesthetics, "bam", guide = "edge_colourbar", |
| 675 | 6x |
reverse = reverse, range = range, midpoint = midpoint, ...) |
| 676 |
} |
|
| 677 |
} |
|
| 678 | ||
| 679 |
#' @export |
|
| 680 |
#' @rdname scale_crameri_bam |
|
| 681 |
scale_edge_color_bam <- scale_edge_colour_bam |
|
| 682 | ||
| 683 |
#' @export |
|
| 684 |
#' @rdname scale_crameri_bam |
|
| 685 |
scale_edge_fill_bam <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 686 |
midpoint = 0, discrete = FALSE, |
|
| 687 |
aesthetics = "edge_fill") {
|
|
| 688 | 4x |
if (discrete) {
|
| 689 | ! |
scale_discrete(aesthetics, "bam", reverse = reverse, ...) |
| 690 |
} else {
|
|
| 691 | 4x |
scale_continuous(aesthetics, "bam", guide = "edge_colourbar", |
| 692 | 4x |
reverse = reverse, range = range, midpoint = midpoint, ...) |
| 693 |
} |
|
| 694 |
} |
|
| 695 | ||
| 696 |
## vanimo ---------------------------------------------------------------------- |
|
| 697 |
#' Fabio Crameri's *vanimo* Diverging Color Scheme |
|
| 698 |
#' |
|
| 699 |
#' @inheritParams scale_crameri_broc |
|
| 700 |
#' @inheritSection crameri Diverging Color Schemes |
|
| 701 |
#' @return A [continuous][ggplot2::continuous_scale] scale. |
|
| 702 |
#' @references |
|
| 703 |
#' Crameri, F. (2018). Geodynamic diagnostics, scientific visualisation and |
|
| 704 |
#' StagLab 3.0. *Geosci. Model Dev.*, 11, 2541-2562. |
|
| 705 |
#' \doi{10.5194/gmd-11-2541-2018}
|
|
| 706 |
#' |
|
| 707 |
#' Crameri, F., Shephard, G. E. & Heron, P. J. (2020). The misuse of colour in |
|
| 708 |
#' science communication. *Nature Communications*, 11, 5444. |
|
| 709 |
#' \doi{10.1038/s41467-020-19160-7}
|
|
| 710 |
#' @source |
|
| 711 |
#' Crameri, F. (2023). Scientific colour maps. *Zenodo*, v8.0.1. |
|
| 712 |
#' \doi{10.5281/zenodo.1243862}
|
|
| 713 |
#' @example inst/examples/ex-crameri-diverging.R |
|
| 714 |
#' @author N. Frerebeau |
|
| 715 |
#' @family diverging color schemes |
|
| 716 |
#' @family Fabio Crameri's color schemes |
|
| 717 |
#' @name scale_crameri_vanimo |
|
| 718 |
#' @rdname scale_crameri_vanimo |
|
| 719 |
NULL |
|
| 720 | ||
| 721 |
#' @export |
|
| 722 |
#' @rdname scale_crameri_vanimo |
|
| 723 |
scale_colour_vanimo <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 724 |
midpoint = 0, discrete = FALSE, |
|
| 725 |
aesthetics = "colour") {
|
|
| 726 | 6x |
if (discrete) {
|
| 727 | ! |
scale_discrete(aesthetics, "vanimo", reverse = reverse, ...) |
| 728 |
} else {
|
|
| 729 | 6x |
scale_continuous(aesthetics, "vanimo", reverse = reverse, range = range, |
| 730 | 6x |
midpoint = midpoint, ...) |
| 731 |
} |
|
| 732 |
} |
|
| 733 | ||
| 734 |
#' @export |
|
| 735 |
#' @rdname scale_crameri_vanimo |
|
| 736 |
scale_color_vanimo <- scale_colour_vanimo |
|
| 737 | ||
| 738 |
#' @export |
|
| 739 |
#' @rdname scale_crameri_vanimo |
|
| 740 |
scale_fill_vanimo <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 741 |
midpoint = 0, discrete = FALSE, |
|
| 742 |
aesthetics = "fill") {
|
|
| 743 | 4x |
if (discrete) {
|
| 744 | ! |
scale_discrete(aesthetics, "vanimo", reverse = reverse, ...) |
| 745 |
} else {
|
|
| 746 | 4x |
scale_continuous(aesthetics, "vanimo", reverse = reverse, range = range, |
| 747 | 4x |
midpoint = midpoint, ...) |
| 748 |
} |
|
| 749 |
} |
|
| 750 | ||
| 751 |
#' @export |
|
| 752 |
#' @rdname scale_crameri_vanimo |
|
| 753 |
scale_edge_colour_vanimo <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 754 |
midpoint = 0, discrete = FALSE, |
|
| 755 |
aesthetics = "edge_colour") {
|
|
| 756 | 6x |
if (discrete) {
|
| 757 | ! |
scale_discrete(aesthetics, "vanimo", reverse = reverse, ...) |
| 758 |
} else {
|
|
| 759 | 6x |
scale_continuous(aesthetics, "vanimo", guide = "edge_colourbar", |
| 760 | 6x |
reverse = reverse, range = range, midpoint = midpoint, ...) |
| 761 |
} |
|
| 762 |
} |
|
| 763 | ||
| 764 |
#' @export |
|
| 765 |
#' @rdname scale_crameri_vanimo |
|
| 766 |
scale_edge_color_vanimo <- scale_edge_colour_vanimo |
|
| 767 | ||
| 768 |
#' @export |
|
| 769 |
#' @rdname scale_crameri_vanimo |
|
| 770 |
scale_edge_fill_vanimo <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 771 |
midpoint = 0, discrete = FALSE, |
|
| 772 |
aesthetics = "edge_fill") {
|
|
| 773 | 4x |
if (discrete) {
|
| 774 | ! |
scale_discrete(aesthetics, "vanimo", reverse = reverse, ...) |
| 775 |
} else {
|
|
| 776 | 4x |
scale_continuous(aesthetics, "vanimo", guide = "edge_colourbar", |
| 777 | 4x |
reverse = reverse, range = range, midpoint = midpoint, ...) |
| 778 |
} |
|
| 779 |
} |
|
| 780 | ||
| 781 |
## managua --------------------------------------------------------------------- |
|
| 782 |
#' Fabio Crameri's *managua* Diverging Color Scheme |
|
| 783 |
#' |
|
| 784 |
#' @inheritParams scale_crameri_broc |
|
| 785 |
#' @inheritSection crameri Diverging Color Schemes |
|
| 786 |
#' @return A [continuous][ggplot2::continuous_scale] scale. |
|
| 787 |
#' @references |
|
| 788 |
#' Crameri, F. (2018). Geodynamic diagnostics, scientific visualisation and |
|
| 789 |
#' StagLab 3.0. *Geosci. Model Dev.*, 11, 2541-2562. |
|
| 790 |
#' \doi{10.5194/gmd-11-2541-2018}
|
|
| 791 |
#' |
|
| 792 |
#' Crameri, F., Shephard, G. E. & Heron, P. J. (2020). The misuse of colour in |
|
| 793 |
#' science communication. *Nature Communications*, 11, 5444. |
|
| 794 |
#' \doi{10.1038/s41467-020-19160-7}
|
|
| 795 |
#' @source |
|
| 796 |
#' Crameri, F. (2023). Scientific colour maps. *Zenodo*, v8.0.1. |
|
| 797 |
#' \doi{10.5281/zenodo.1243862}
|
|
| 798 |
#' @example inst/examples/ex-crameri-diverging.R |
|
| 799 |
#' @author N. Frerebeau |
|
| 800 |
#' @family diverging color schemes |
|
| 801 |
#' @family Fabio Crameri's color schemes |
|
| 802 |
#' @name scale_crameri_managua |
|
| 803 |
#' @rdname scale_crameri_managua |
|
| 804 |
NULL |
|
| 805 | ||
| 806 |
#' @export |
|
| 807 |
#' @rdname scale_crameri_managua |
|
| 808 |
scale_colour_managua <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 809 |
midpoint = 0, discrete = FALSE, |
|
| 810 |
aesthetics = "colour") {
|
|
| 811 | 6x |
if (discrete) {
|
| 812 | ! |
scale_discrete(aesthetics, "managua", reverse = reverse, ...) |
| 813 |
} else {
|
|
| 814 | 6x |
scale_continuous(aesthetics, "managua", reverse = reverse, range = range, |
| 815 | 6x |
midpoint = midpoint, ...) |
| 816 |
} |
|
| 817 |
} |
|
| 818 | ||
| 819 |
#' @export |
|
| 820 |
#' @rdname scale_crameri_managua |
|
| 821 |
scale_color_managua <- scale_colour_managua |
|
| 822 | ||
| 823 |
#' @export |
|
| 824 |
#' @rdname scale_crameri_managua |
|
| 825 |
scale_fill_managua <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 826 |
midpoint = 0, discrete = FALSE, |
|
| 827 |
aesthetics = "fill") {
|
|
| 828 | 4x |
if (discrete) {
|
| 829 | ! |
scale_discrete(aesthetics, "managua", reverse = reverse, ...) |
| 830 |
} else {
|
|
| 831 | 4x |
scale_continuous(aesthetics, "managua", reverse = reverse, range = range, |
| 832 | 4x |
midpoint = midpoint, ...) |
| 833 |
} |
|
| 834 |
} |
|
| 835 | ||
| 836 |
#' @export |
|
| 837 |
#' @rdname scale_crameri_managua |
|
| 838 |
scale_edge_colour_managua <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 839 |
midpoint = 0, discrete = FALSE, |
|
| 840 |
aesthetics = "edge_colour") {
|
|
| 841 | ! |
if (discrete) {
|
| 842 | ! |
scale_discrete(aesthetics, "managua", reverse = reverse, ...) |
| 843 |
} else {
|
|
| 844 | ! |
scale_continuous(aesthetics, "managua", guide = "edge_colourbar", |
| 845 | ! |
reverse = reverse, range = range, midpoint = midpoint, ...) |
| 846 |
} |
|
| 847 |
} |
|
| 848 | ||
| 849 |
#' @export |
|
| 850 |
#' @rdname scale_crameri_managua |
|
| 851 |
scale_edge_color_managua <- scale_edge_colour_managua |
|
| 852 | ||
| 853 |
#' @export |
|
| 854 |
#' @rdname scale_crameri_managua |
|
| 855 |
scale_edge_fill_managua <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 856 |
midpoint = 0, discrete = FALSE, |
|
| 857 |
aesthetics = "edge_fill") {
|
|
| 858 | ! |
if (discrete) {
|
| 859 | ! |
scale_discrete(aesthetics, "managua", reverse = reverse, ...) |
| 860 |
} else {
|
|
| 861 | ! |
scale_continuous(aesthetics, "managua", guide = "edge_colourbar", |
| 862 | ! |
reverse = reverse, range = range, midpoint = midpoint, ...) |
| 863 |
} |
|
| 864 |
} |
|
| 865 | ||
| 866 |
# Sequential =================================================================== |
|
| 867 |
## batlow ---------------------------------------------------------------------- |
|
| 868 |
#' Fabio Crameri's *batlow* Sequential Color Scheme |
|
| 869 |
#' |
|
| 870 |
#' @param ... Arguments passed to [ggplot2::continuous_scale()]. |
|
| 871 |
#' @param reverse A [`logical`] scalar. Should the resulting |
|
| 872 |
#' vector of colors be reversed? |
|
| 873 |
#' @param range A length-two [`numeric`] vector specifying the |
|
| 874 |
#' fraction of the scheme's color domain to keep. |
|
| 875 |
#' @param aesthetics A [`character`] string or vector of character |
|
| 876 |
#' strings listing the name(s) of the aesthetic(s) that this scale works with. |
|
| 877 |
#' @param discrete A [`logical`] scalar: should the color scheme be |
|
| 878 |
#' used as a discrete scale? |
|
| 879 |
#' @inheritSection crameri Sequential Color Schemes |
|
| 880 |
#' @return A [continuous][ggplot2::continuous_scale] scale. |
|
| 881 |
#' @references |
|
| 882 |
#' Crameri, F. (2018). Geodynamic diagnostics, scientific visualisation and |
|
| 883 |
#' StagLab 3.0. *Geosci. Model Dev.*, 11, 2541-2562. |
|
| 884 |
#' \doi{10.5194/gmd-11-2541-2018}
|
|
| 885 |
#' |
|
| 886 |
#' Crameri, F., Shephard, G. E. & Heron, P. J. (2020). The misuse of colour in |
|
| 887 |
#' science communication. *Nature Communications*, 11, 5444. |
|
| 888 |
#' \doi{10.1038/s41467-020-19160-7}
|
|
| 889 |
#' @source |
|
| 890 |
#' Crameri, F. (2023). Scientific colour maps. *Zenodo*, v8.0.1. |
|
| 891 |
#' \doi{10.5281/zenodo.1243862}
|
|
| 892 |
#' @example inst/examples/ex-crameri-sequential.R |
|
| 893 |
#' @author N. Frerebeau |
|
| 894 |
#' @family sequential color schemes |
|
| 895 |
#' @family Fabio Crameri's color schemes |
|
| 896 |
#' @name scale_crameri_batlow |
|
| 897 |
#' @rdname scale_crameri_batlow |
|
| 898 |
NULL |
|
| 899 | ||
| 900 |
#' @export |
|
| 901 |
#' @rdname scale_crameri_batlow |
|
| 902 |
scale_colour_batlow <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 903 |
discrete = FALSE, aesthetics = "colour") {
|
|
| 904 | 5x |
if (discrete) {
|
| 905 | 1x |
scale_discrete(aesthetics, "batlow", reverse = reverse, ...) |
| 906 |
} else {
|
|
| 907 | 4x |
scale_continuous(aesthetics, "batlow", reverse = reverse, |
| 908 | 4x |
range = range, ...) |
| 909 |
} |
|
| 910 |
} |
|
| 911 | ||
| 912 |
#' @export |
|
| 913 |
#' @rdname scale_crameri_batlow |
|
| 914 |
scale_color_batlow <- scale_colour_batlow |
|
| 915 | ||
| 916 |
#' @export |
|
| 917 |
#' @rdname scale_crameri_batlow |
|
| 918 |
scale_fill_batlow <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 919 |
discrete = FALSE, aesthetics = "fill") {
|
|
| 920 | 3x |
if (discrete) {
|
| 921 | 1x |
scale_discrete(aesthetics, "batlow", reverse = reverse, ...) |
| 922 |
} else {
|
|
| 923 | 2x |
scale_continuous(aesthetics, "batlow", reverse = reverse, |
| 924 | 2x |
range = range, ...) |
| 925 |
} |
|
| 926 |
} |
|
| 927 | ||
| 928 |
#' @export |
|
| 929 |
#' @rdname scale_crameri_batlow |
|
| 930 |
scale_edge_colour_batlow <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 931 |
discrete = FALSE, |
|
| 932 |
aesthetics = "edge_colour") {
|
|
| 933 | 5x |
if (discrete) {
|
| 934 | 1x |
scale_discrete(aesthetics, "batlow", reverse = reverse, ...) |
| 935 |
} else {
|
|
| 936 | 4x |
scale_continuous(aesthetics, "batlow", guide = "edge_colourbar", |
| 937 | 4x |
reverse = reverse, range = range, ...) |
| 938 |
} |
|
| 939 |
} |
|
| 940 | ||
| 941 |
#' @export |
|
| 942 |
#' @rdname scale_crameri_batlow |
|
| 943 |
scale_edge_color_batlow <- scale_edge_colour_batlow |
|
| 944 | ||
| 945 |
#' @export |
|
| 946 |
#' @rdname scale_crameri_batlow |
|
| 947 |
scale_edge_fill_batlow <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 948 |
discrete = FALSE, |
|
| 949 |
aesthetics = "edge_fill") {
|
|
| 950 | 3x |
if (discrete) {
|
| 951 | 1x |
scale_discrete(aesthetics, "batlow", reverse = reverse, ...) |
| 952 |
} else {
|
|
| 953 | 2x |
scale_continuous(aesthetics, "batlow", guide = "edge_colourbar", |
| 954 | 2x |
reverse = reverse, range = range, ...) |
| 955 |
} |
|
| 956 |
} |
|
| 957 | ||
| 958 |
## batlowW --------------------------------------------------------------------- |
|
| 959 |
#' Fabio Crameri's *batlowW* Sequential Color Scheme |
|
| 960 |
#' |
|
| 961 |
#' @inheritParams scale_crameri_batlow |
|
| 962 |
#' @inheritSection crameri Sequential Color Schemes |
|
| 963 |
#' @return A [continuous][ggplot2::continuous_scale] scale. |
|
| 964 |
#' @references |
|
| 965 |
#' Crameri, F. (2018). Geodynamic diagnostics, scientific visualisation and |
|
| 966 |
#' StagLab 3.0. *Geosci. Model Dev.*, 11, 2541-2562. |
|
| 967 |
#' \doi{10.5194/gmd-11-2541-2018}
|
|
| 968 |
#' |
|
| 969 |
#' Crameri, F., Shephard, G. E. & Heron, P. J. (2020). The misuse of colour in |
|
| 970 |
#' science communication. *Nature Communications*, 11, 5444. |
|
| 971 |
#' \doi{10.1038/s41467-020-19160-7}
|
|
| 972 |
#' @source |
|
| 973 |
#' Crameri, F. (2023). Scientific colour maps. *Zenodo*, v8.0.1. |
|
| 974 |
#' \doi{10.5281/zenodo.1243862}
|
|
| 975 |
#' @example inst/examples/ex-crameri-sequential.R |
|
| 976 |
#' @author N. Frerebeau |
|
| 977 |
#' @family sequential color schemes |
|
| 978 |
#' @family Fabio Crameri's color schemes |
|
| 979 |
#' @name scale_crameri_batlowW |
|
| 980 |
#' @rdname scale_crameri_batlowW |
|
| 981 |
NULL |
|
| 982 | ||
| 983 |
#' @export |
|
| 984 |
#' @rdname scale_crameri_batlowW |
|
| 985 |
scale_colour_batlowW <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 986 |
discrete = FALSE, aesthetics = "colour") {
|
|
| 987 | 5x |
if (discrete) {
|
| 988 | 1x |
scale_discrete(aesthetics, "batlowW", reverse = reverse, ...) |
| 989 |
} else {
|
|
| 990 | 4x |
scale_continuous(aesthetics, "batlowW", reverse = reverse, |
| 991 | 4x |
range = range, ...) |
| 992 |
} |
|
| 993 |
} |
|
| 994 | ||
| 995 |
#' @export |
|
| 996 |
#' @rdname scale_crameri_batlowW |
|
| 997 |
scale_color_batlowW <- scale_colour_batlowW |
|
| 998 | ||
| 999 |
#' @export |
|
| 1000 |
#' @rdname scale_crameri_batlowW |
|
| 1001 |
scale_fill_batlowW <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1002 |
discrete = FALSE, aesthetics = "fill") {
|
|
| 1003 | 3x |
if (discrete) {
|
| 1004 | 1x |
scale_discrete(aesthetics, "batlowW", reverse = reverse, ...) |
| 1005 |
} else {
|
|
| 1006 | 2x |
scale_continuous(aesthetics, "batlowW", reverse = reverse, |
| 1007 | 2x |
range = range, ...) |
| 1008 |
} |
|
| 1009 |
} |
|
| 1010 | ||
| 1011 |
#' @export |
|
| 1012 |
#' @rdname scale_crameri_batlowW |
|
| 1013 |
scale_edge_colour_batlowW <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1014 |
discrete = FALSE, |
|
| 1015 |
aesthetics = "edge_colour") {
|
|
| 1016 | 5x |
if (discrete) {
|
| 1017 | 1x |
scale_discrete(aesthetics, "batlowW", reverse = reverse, ...) |
| 1018 |
} else {
|
|
| 1019 | 4x |
scale_continuous(aesthetics, "batlowW", guide = "edge_colourbar", |
| 1020 | 4x |
reverse = reverse, range = range, ...) |
| 1021 |
} |
|
| 1022 |
} |
|
| 1023 | ||
| 1024 |
#' @export |
|
| 1025 |
#' @rdname scale_crameri_batlowW |
|
| 1026 |
scale_edge_color_batlowW <- scale_edge_colour_batlowW |
|
| 1027 | ||
| 1028 |
#' @export |
|
| 1029 |
#' @rdname scale_crameri_batlowW |
|
| 1030 |
scale_edge_fill_batlowW <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1031 |
discrete = FALSE, |
|
| 1032 |
aesthetics = "edge_fill") {
|
|
| 1033 | 3x |
if (discrete) {
|
| 1034 | 1x |
scale_discrete(aesthetics, "batlowW", reverse = reverse, ...) |
| 1035 |
} else {
|
|
| 1036 | 2x |
scale_continuous(aesthetics, "batlowW", guide = "edge_colourbar", |
| 1037 | 2x |
reverse = reverse, range = range, ...) |
| 1038 |
} |
|
| 1039 |
} |
|
| 1040 | ||
| 1041 |
## batlowK --------------------------------------------------------------------- |
|
| 1042 |
#' Fabio Crameri's *batlowK* Sequential Color Scheme |
|
| 1043 |
#' |
|
| 1044 |
#' @inheritParams scale_crameri_batlow |
|
| 1045 |
#' @inheritSection crameri Sequential Color Schemes |
|
| 1046 |
#' @return A [continuous][ggplot2::continuous_scale] scale. |
|
| 1047 |
#' @references |
|
| 1048 |
#' Crameri, F. (2018). Geodynamic diagnostics, scientific visualisation and |
|
| 1049 |
#' StagLab 3.0. *Geosci. Model Dev.*, 11, 2541-2562. |
|
| 1050 |
#' \doi{10.5194/gmd-11-2541-2018}
|
|
| 1051 |
#' |
|
| 1052 |
#' Crameri, F., Shephard, G. E. & Heron, P. J. (2020). The misuse of colour in |
|
| 1053 |
#' science communication. *Nature Communications*, 11, 5444. |
|
| 1054 |
#' \doi{10.1038/s41467-020-19160-7}
|
|
| 1055 |
#' @source |
|
| 1056 |
#' Crameri, F. (2023). Scientific colour maps. *Zenodo*, v8.0.1. |
|
| 1057 |
#' \doi{10.5281/zenodo.1243862}
|
|
| 1058 |
#' @example inst/examples/ex-crameri-sequential.R |
|
| 1059 |
#' @author N. Frerebeau |
|
| 1060 |
#' @family sequential color schemes |
|
| 1061 |
#' @family Fabio Crameri's color schemes |
|
| 1062 |
#' @name scale_crameri_batlowK |
|
| 1063 |
#' @rdname scale_crameri_batlowK |
|
| 1064 |
NULL |
|
| 1065 | ||
| 1066 |
#' @export |
|
| 1067 |
#' @rdname scale_crameri_batlowK |
|
| 1068 |
scale_colour_batlowK <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1069 |
discrete = FALSE, aesthetics = "colour") {
|
|
| 1070 | 5x |
if (discrete) {
|
| 1071 | 1x |
scale_discrete(aesthetics, "batlowK", reverse = reverse, ...) |
| 1072 |
} else {
|
|
| 1073 | 4x |
scale_continuous(aesthetics, "batlowK", reverse = reverse, |
| 1074 | 4x |
range = range, ...) |
| 1075 |
} |
|
| 1076 |
} |
|
| 1077 | ||
| 1078 |
#' @export |
|
| 1079 |
#' @rdname scale_crameri_batlowK |
|
| 1080 |
scale_color_batlowK <- scale_colour_batlowK |
|
| 1081 | ||
| 1082 |
#' @export |
|
| 1083 |
#' @rdname scale_crameri_batlowK |
|
| 1084 |
scale_fill_batlowK <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1085 |
discrete = FALSE, aesthetics = "fill") {
|
|
| 1086 | 3x |
if (discrete) {
|
| 1087 | 1x |
scale_discrete(aesthetics, "batlowK", reverse = reverse, ...) |
| 1088 |
} else {
|
|
| 1089 | 2x |
scale_continuous(aesthetics, "batlowK", reverse = reverse, |
| 1090 | 2x |
range = range, ...) |
| 1091 |
} |
|
| 1092 |
} |
|
| 1093 | ||
| 1094 |
#' @export |
|
| 1095 |
#' @rdname scale_crameri_batlowK |
|
| 1096 |
scale_edge_colour_batlowK <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1097 |
discrete = FALSE, |
|
| 1098 |
aesthetics = "edge_colour") {
|
|
| 1099 | 5x |
if (discrete) {
|
| 1100 | 1x |
scale_discrete(aesthetics, "batlowK", reverse = reverse, ...) |
| 1101 |
} else {
|
|
| 1102 | 4x |
scale_continuous(aesthetics, "batlowK", guide = "edge_colourbar", |
| 1103 | 4x |
reverse = reverse, range = range, ...) |
| 1104 |
} |
|
| 1105 |
} |
|
| 1106 | ||
| 1107 |
#' @export |
|
| 1108 |
#' @rdname scale_crameri_batlowK |
|
| 1109 |
scale_edge_color_batlowK <- scale_edge_colour_batlowK |
|
| 1110 | ||
| 1111 |
#' @export |
|
| 1112 |
#' @rdname scale_crameri_batlowK |
|
| 1113 |
scale_edge_fill_batlowK <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1114 |
discrete = FALSE, |
|
| 1115 |
aesthetics = "edge_fill") {
|
|
| 1116 | 3x |
if (discrete) {
|
| 1117 | 1x |
scale_discrete(aesthetics, "batlowK", reverse = reverse, ...) |
| 1118 |
} else {
|
|
| 1119 | 2x |
scale_continuous(aesthetics, "batlowK", guide = "edge_colourbar", |
| 1120 | 2x |
reverse = reverse, range = range, ...) |
| 1121 |
} |
|
| 1122 |
} |
|
| 1123 | ||
| 1124 |
## devon ----------------------------------------------------------------------- |
|
| 1125 |
#' Fabio Crameri's *devon* Sequential Color Scheme |
|
| 1126 |
#' |
|
| 1127 |
#' @inheritParams scale_crameri_batlow |
|
| 1128 |
#' @inheritSection crameri Sequential Color Schemes |
|
| 1129 |
#' @return A [continuous][ggplot2::continuous_scale] scale. |
|
| 1130 |
#' @references |
|
| 1131 |
#' Crameri, F. (2018). Geodynamic diagnostics, scientific visualisation and |
|
| 1132 |
#' StagLab 3.0. *Geosci. Model Dev.*, 11, 2541-2562. |
|
| 1133 |
#' \doi{10.5194/gmd-11-2541-2018}
|
|
| 1134 |
#' |
|
| 1135 |
#' Crameri, F., Shephard, G. E. & Heron, P. J. (2020). The misuse of colour in |
|
| 1136 |
#' science communication. *Nature Communications*, 11, 5444. |
|
| 1137 |
#' \doi{10.1038/s41467-020-19160-7}
|
|
| 1138 |
#' @source |
|
| 1139 |
#' Crameri, F. (2023). Scientific colour maps. *Zenodo*, v8.0.1. |
|
| 1140 |
#' \doi{10.5281/zenodo.1243862}
|
|
| 1141 |
#' @example inst/examples/ex-crameri-sequential.R |
|
| 1142 |
#' @author N. Frerebeau |
|
| 1143 |
#' @family sequential color schemes |
|
| 1144 |
#' @family Fabio Crameri's color schemes |
|
| 1145 |
#' @name scale_crameri_devon |
|
| 1146 |
#' @rdname scale_crameri_devon |
|
| 1147 |
NULL |
|
| 1148 | ||
| 1149 |
#' @export |
|
| 1150 |
#' @rdname scale_crameri_devon |
|
| 1151 |
scale_colour_devon <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1152 |
discrete = FALSE, aesthetics = "colour") {
|
|
| 1153 | 5x |
if (discrete) {
|
| 1154 | 1x |
scale_discrete(aesthetics, "devon", reverse = reverse, ...) |
| 1155 |
} else {
|
|
| 1156 | 4x |
scale_continuous(aesthetics, "devon", reverse = reverse, |
| 1157 | 4x |
range = range, ...) |
| 1158 |
} |
|
| 1159 |
} |
|
| 1160 | ||
| 1161 |
#' @export |
|
| 1162 |
#' @rdname scale_crameri_devon |
|
| 1163 |
scale_color_devon <- scale_colour_devon |
|
| 1164 | ||
| 1165 |
#' @export |
|
| 1166 |
#' @rdname scale_crameri_devon |
|
| 1167 |
scale_fill_devon <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1168 |
discrete = FALSE, aesthetics = "fill") {
|
|
| 1169 | 3x |
if (discrete) {
|
| 1170 | 1x |
scale_discrete(aesthetics, "devon", reverse = reverse, ...) |
| 1171 |
} else {
|
|
| 1172 | 2x |
scale_continuous(aesthetics, "devon", reverse = reverse, |
| 1173 | 2x |
range = range, ...) |
| 1174 |
} |
|
| 1175 |
} |
|
| 1176 | ||
| 1177 |
#' @export |
|
| 1178 |
#' @rdname scale_crameri_devon |
|
| 1179 |
scale_edge_colour_devon <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1180 |
discrete = FALSE, |
|
| 1181 |
aesthetics = "edge_colour") {
|
|
| 1182 | 5x |
if (discrete) {
|
| 1183 | 1x |
scale_discrete(aesthetics, "devon", reverse = reverse, ...) |
| 1184 |
} else {
|
|
| 1185 | 4x |
scale_continuous(aesthetics, "devon", guide = "edge_colourbar", |
| 1186 | 4x |
reverse = reverse, range = range, ...) |
| 1187 |
} |
|
| 1188 |
} |
|
| 1189 | ||
| 1190 |
#' @export |
|
| 1191 |
#' @rdname scale_crameri_devon |
|
| 1192 |
scale_edge_color_devon <- scale_edge_colour_devon |
|
| 1193 | ||
| 1194 |
#' @export |
|
| 1195 |
#' @rdname scale_crameri_devon |
|
| 1196 |
scale_edge_fill_devon <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1197 |
discrete = FALSE, |
|
| 1198 |
aesthetics = "edge_fill") {
|
|
| 1199 | 3x |
if (discrete) {
|
| 1200 | 1x |
scale_discrete(aesthetics, "devon", reverse = reverse, ...) |
| 1201 |
} else {
|
|
| 1202 | 2x |
scale_continuous(aesthetics, "devon", guide = "edge_colourbar", |
| 1203 | 2x |
reverse = reverse, range = range, ...) |
| 1204 |
} |
|
| 1205 |
} |
|
| 1206 | ||
| 1207 |
## lajolla --------------------------------------------------------------------- |
|
| 1208 |
#' Fabio Crameri's *lajolla* Sequential Color Scheme |
|
| 1209 |
#' |
|
| 1210 |
#' @inheritParams scale_crameri_batlow |
|
| 1211 |
#' @inheritSection crameri Sequential Color Schemes |
|
| 1212 |
#' @return A [continuous][ggplot2::continuous_scale] scale. |
|
| 1213 |
#' @references |
|
| 1214 |
#' Crameri, F. (2018). Geodynamic diagnostics, scientific visualisation and |
|
| 1215 |
#' StagLab 3.0. *Geosci. Model Dev.*, 11, 2541-2562. |
|
| 1216 |
#' \doi{10.5194/gmd-11-2541-2018}
|
|
| 1217 |
#' |
|
| 1218 |
#' Crameri, F., Shephard, G. E. & Heron, P. J. (2020). The misuse of colour in |
|
| 1219 |
#' science communication. *Nature Communications*, 11, 5444. |
|
| 1220 |
#' \doi{10.1038/s41467-020-19160-7}
|
|
| 1221 |
#' @source |
|
| 1222 |
#' Crameri, F. (2023). Scientific colour maps. *Zenodo*, v8.0.1. |
|
| 1223 |
#' \doi{10.5281/zenodo.1243862}
|
|
| 1224 |
#' @example inst/examples/ex-crameri-sequential.R |
|
| 1225 |
#' @author N. Frerebeau |
|
| 1226 |
#' @family sequential color schemes |
|
| 1227 |
#' @family Fabio Crameri's color schemes |
|
| 1228 |
#' @name scale_crameri_lajolla |
|
| 1229 |
#' @rdname scale_crameri_lajolla |
|
| 1230 |
NULL |
|
| 1231 | ||
| 1232 |
#' @export |
|
| 1233 |
#' @rdname scale_crameri_lajolla |
|
| 1234 |
scale_colour_lajolla <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1235 |
discrete = FALSE, aesthetics = "colour") {
|
|
| 1236 | 5x |
if (discrete) {
|
| 1237 | 1x |
scale_discrete(aesthetics, "lajolla", reverse = reverse, ...) |
| 1238 |
} else {
|
|
| 1239 | 4x |
scale_continuous(aesthetics, "lajolla", reverse = reverse, |
| 1240 | 4x |
range = range, ...) |
| 1241 |
} |
|
| 1242 |
} |
|
| 1243 | ||
| 1244 |
#' @export |
|
| 1245 |
#' @rdname scale_crameri_lajolla |
|
| 1246 |
scale_color_lajolla <- scale_colour_lajolla |
|
| 1247 | ||
| 1248 |
#' @export |
|
| 1249 |
#' @rdname scale_crameri_lajolla |
|
| 1250 |
scale_fill_lajolla <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1251 |
discrete = FALSE, aesthetics = "fill") {
|
|
| 1252 | 3x |
if (discrete) {
|
| 1253 | 1x |
scale_discrete(aesthetics, "lajolla", reverse = reverse, ...) |
| 1254 |
} else {
|
|
| 1255 | 2x |
scale_continuous(aesthetics, "lajolla", reverse = reverse, |
| 1256 | 2x |
range = range, ...) |
| 1257 |
} |
|
| 1258 |
} |
|
| 1259 | ||
| 1260 |
#' @export |
|
| 1261 |
#' @rdname scale_crameri_lajolla |
|
| 1262 |
scale_edge_colour_lajolla <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1263 |
discrete = FALSE, |
|
| 1264 |
aesthetics = "edge_colour") {
|
|
| 1265 | 5x |
if (discrete) {
|
| 1266 | 1x |
scale_discrete(aesthetics, "lajolla", reverse = reverse, ...) |
| 1267 |
} else {
|
|
| 1268 | 4x |
scale_continuous(aesthetics, "lajolla", guide = "edge_colourbar", |
| 1269 | 4x |
reverse = reverse, range = range, ...) |
| 1270 |
} |
|
| 1271 |
} |
|
| 1272 | ||
| 1273 |
#' @export |
|
| 1274 |
#' @rdname scale_crameri_lajolla |
|
| 1275 |
scale_edge_color_lajolla <- scale_edge_colour_lajolla |
|
| 1276 | ||
| 1277 |
#' @export |
|
| 1278 |
#' @rdname scale_crameri_lajolla |
|
| 1279 |
scale_edge_fill_lajolla <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1280 |
discrete = FALSE, |
|
| 1281 |
aesthetics = "edge_fill") {
|
|
| 1282 | 3x |
if (discrete) {
|
| 1283 | 1x |
scale_discrete(aesthetics, "lajolla", reverse = reverse, ...) |
| 1284 |
} else {
|
|
| 1285 | 2x |
scale_continuous(aesthetics, "lajolla", guide = "edge_colourbar", |
| 1286 | 2x |
reverse = reverse, range = range, ...) |
| 1287 |
} |
|
| 1288 |
} |
|
| 1289 | ||
| 1290 |
## bamako ---------------------------------------------------------------------- |
|
| 1291 |
#' Fabio Crameri's *bamako* Sequential Color Scheme |
|
| 1292 |
#' |
|
| 1293 |
#' @inheritParams scale_crameri_batlow |
|
| 1294 |
#' @inheritSection crameri Sequential Color Schemes |
|
| 1295 |
#' @return A [continuous][ggplot2::continuous_scale] scale. |
|
| 1296 |
#' @references |
|
| 1297 |
#' Crameri, F. (2018). Geodynamic diagnostics, scientific visualisation and |
|
| 1298 |
#' StagLab 3.0. *Geosci. Model Dev.*, 11, 2541-2562. |
|
| 1299 |
#' \doi{10.5194/gmd-11-2541-2018}
|
|
| 1300 |
#' |
|
| 1301 |
#' Crameri, F., Shephard, G. E. & Heron, P. J. (2020). The misuse of colour in |
|
| 1302 |
#' science communication. *Nature Communications*, 11, 5444. |
|
| 1303 |
#' \doi{10.1038/s41467-020-19160-7}
|
|
| 1304 |
#' @source |
|
| 1305 |
#' Crameri, F. (2023). Scientific colour maps. *Zenodo*, v8.0.1. |
|
| 1306 |
#' \doi{10.5281/zenodo.1243862}
|
|
| 1307 |
#' @example inst/examples/ex-crameri-sequential.R |
|
| 1308 |
#' @author N. Frerebeau |
|
| 1309 |
#' @family sequential color schemes |
|
| 1310 |
#' @family Fabio Crameri's color schemes |
|
| 1311 |
#' @name scale_crameri_bamako |
|
| 1312 |
#' @rdname scale_crameri_bamako |
|
| 1313 |
NULL |
|
| 1314 | ||
| 1315 |
#' @export |
|
| 1316 |
#' @rdname scale_crameri_bamako |
|
| 1317 |
scale_colour_bamako <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1318 |
discrete = FALSE, aesthetics = "colour") {
|
|
| 1319 | 5x |
if (discrete) {
|
| 1320 | 1x |
scale_discrete(aesthetics, "bamako", reverse = reverse, ...) |
| 1321 |
} else {
|
|
| 1322 | 4x |
scale_continuous(aesthetics, "bamako", reverse = reverse, |
| 1323 | 4x |
range = range, ...) |
| 1324 |
} |
|
| 1325 |
} |
|
| 1326 | ||
| 1327 |
#' @export |
|
| 1328 |
#' @rdname scale_crameri_bamako |
|
| 1329 |
scale_color_bamako <- scale_colour_bamako |
|
| 1330 | ||
| 1331 |
#' @export |
|
| 1332 |
#' @rdname scale_crameri_bamako |
|
| 1333 |
scale_fill_bamako <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1334 |
discrete = FALSE, aesthetics = "fill") {
|
|
| 1335 | 3x |
if (discrete) {
|
| 1336 | 1x |
scale_discrete(aesthetics, "bamako", reverse = reverse, ...) |
| 1337 |
} else {
|
|
| 1338 | 2x |
scale_continuous(aesthetics, "bamako", reverse = reverse, |
| 1339 | 2x |
range = range, ...) |
| 1340 |
} |
|
| 1341 |
} |
|
| 1342 | ||
| 1343 |
#' @export |
|
| 1344 |
#' @rdname scale_crameri_bamako |
|
| 1345 |
scale_edge_colour_bamako <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1346 |
discrete = FALSE, |
|
| 1347 |
aesthetics = "edge_colour") {
|
|
| 1348 | 5x |
if (discrete) {
|
| 1349 | 1x |
scale_discrete(aesthetics, "bamako", reverse = reverse, ...) |
| 1350 |
} else {
|
|
| 1351 | 4x |
scale_continuous(aesthetics, "bamako", guide = "edge_colourbar", |
| 1352 | 4x |
reverse = reverse, range = range, ...) |
| 1353 |
} |
|
| 1354 |
} |
|
| 1355 | ||
| 1356 |
#' @export |
|
| 1357 |
#' @rdname scale_crameri_bamako |
|
| 1358 |
scale_edge_color_bamako <- scale_edge_colour_bamako |
|
| 1359 | ||
| 1360 |
#' @export |
|
| 1361 |
#' @rdname scale_crameri_bamako |
|
| 1362 |
scale_edge_fill_bamako <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1363 |
discrete = FALSE, |
|
| 1364 |
aesthetics = "edge_fill") {
|
|
| 1365 | 3x |
if (discrete) {
|
| 1366 | 1x |
scale_discrete(aesthetics, "bamako", reverse = reverse, ...) |
| 1367 |
} else {
|
|
| 1368 | 2x |
scale_continuous(aesthetics, "bamako", guide = "edge_colourbar", |
| 1369 | 2x |
reverse = reverse, range = range, ...) |
| 1370 |
} |
|
| 1371 |
} |
|
| 1372 | ||
| 1373 |
## davos ----------------------------------------------------------------------- |
|
| 1374 |
#' Fabio Crameri's *davos* Sequential Color Scheme |
|
| 1375 |
#' |
|
| 1376 |
#' @inheritParams scale_crameri_batlow |
|
| 1377 |
#' @inheritSection crameri Sequential Color Schemes |
|
| 1378 |
#' @return A [continuous][ggplot2::continuous_scale] scale. |
|
| 1379 |
#' @references |
|
| 1380 |
#' Crameri, F. (2018). Geodynamic diagnostics, scientific visualisation and |
|
| 1381 |
#' StagLab 3.0. *Geosci. Model Dev.*, 11, 2541-2562. |
|
| 1382 |
#' \doi{10.5194/gmd-11-2541-2018}
|
|
| 1383 |
#' |
|
| 1384 |
#' Crameri, F., Shephard, G. E. & Heron, P. J. (2020). The misuse of colour in |
|
| 1385 |
#' science communication. *Nature Communications*, 11, 5444. |
|
| 1386 |
#' \doi{10.1038/s41467-020-19160-7}
|
|
| 1387 |
#' @source |
|
| 1388 |
#' Crameri, F. (2023). Scientific colour maps. *Zenodo*, v8.0.1. |
|
| 1389 |
#' \doi{10.5281/zenodo.1243862}
|
|
| 1390 |
#' @example inst/examples/ex-crameri-sequential.R |
|
| 1391 |
#' @author N. Frerebeau |
|
| 1392 |
#' @family sequential color schemes |
|
| 1393 |
#' @family Fabio Crameri's color schemes |
|
| 1394 |
#' @name scale_crameri_davos |
|
| 1395 |
#' @rdname scale_crameri_davos |
|
| 1396 |
NULL |
|
| 1397 | ||
| 1398 |
#' @export |
|
| 1399 |
#' @rdname scale_crameri_davos |
|
| 1400 |
scale_colour_davos <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1401 |
discrete = FALSE, aesthetics = "colour") {
|
|
| 1402 | 5x |
if (discrete) {
|
| 1403 | 1x |
scale_discrete(aesthetics, "davos", reverse = reverse, ...) |
| 1404 |
} else {
|
|
| 1405 | 4x |
scale_continuous(aesthetics, "davos", reverse = reverse, |
| 1406 | 4x |
range = range, ...) |
| 1407 |
} |
|
| 1408 |
} |
|
| 1409 | ||
| 1410 |
#' @export |
|
| 1411 |
#' @rdname scale_crameri_davos |
|
| 1412 |
scale_color_davos <- scale_colour_davos |
|
| 1413 | ||
| 1414 |
#' @export |
|
| 1415 |
#' @rdname scale_crameri_davos |
|
| 1416 |
scale_fill_davos <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1417 |
discrete = FALSE, aesthetics = "fill") {
|
|
| 1418 | 3x |
if (discrete) {
|
| 1419 | 1x |
scale_discrete(aesthetics, "davos", reverse = reverse, ...) |
| 1420 |
} else {
|
|
| 1421 | 2x |
scale_continuous(aesthetics, "davos", reverse = reverse, |
| 1422 | 2x |
range = range, ...) |
| 1423 |
} |
|
| 1424 |
} |
|
| 1425 | ||
| 1426 |
#' @export |
|
| 1427 |
#' @rdname scale_crameri_davos |
|
| 1428 |
scale_edge_colour_davos <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1429 |
discrete = FALSE, |
|
| 1430 |
aesthetics = "edge_colour") {
|
|
| 1431 | 5x |
if (discrete) {
|
| 1432 | 1x |
scale_discrete(aesthetics, "davos", reverse = reverse, ...) |
| 1433 |
} else {
|
|
| 1434 | 4x |
scale_continuous(aesthetics, "davos", guide = "edge_colourbar", |
| 1435 | 4x |
reverse = reverse, range = range, ...) |
| 1436 |
} |
|
| 1437 |
} |
|
| 1438 | ||
| 1439 |
#' @export |
|
| 1440 |
#' @rdname scale_crameri_davos |
|
| 1441 |
scale_edge_color_davos <- scale_edge_colour_davos |
|
| 1442 | ||
| 1443 |
#' @export |
|
| 1444 |
#' @rdname scale_crameri_davos |
|
| 1445 |
scale_edge_fill_davos <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1446 |
discrete = FALSE, |
|
| 1447 |
aesthetics = "edge_fill") {
|
|
| 1448 | 3x |
if (discrete) {
|
| 1449 | 1x |
scale_discrete(aesthetics, "davos", reverse = reverse, ...) |
| 1450 |
} else {
|
|
| 1451 | 2x |
scale_continuous(aesthetics, "davos", guide = "edge_colourbar", |
| 1452 | 2x |
reverse = reverse, range = range, ...) |
| 1453 |
} |
|
| 1454 |
} |
|
| 1455 | ||
| 1456 |
## bilbao ---------------------------------------------------------------------- |
|
| 1457 |
#' Fabio Crameri's *bilbao* Sequential Color Scheme |
|
| 1458 |
#' |
|
| 1459 |
#' @inheritParams scale_crameri_batlow |
|
| 1460 |
#' @inheritSection crameri Sequential Color Schemes |
|
| 1461 |
#' @return A [continuous][ggplot2::continuous_scale] scale. |
|
| 1462 |
#' @references |
|
| 1463 |
#' Crameri, F. (2018). Geodynamic diagnostics, scientific visualisation and |
|
| 1464 |
#' StagLab 3.0. *Geosci. Model Dev.*, 11, 2541-2562. |
|
| 1465 |
#' \doi{10.5194/gmd-11-2541-2018}
|
|
| 1466 |
#' |
|
| 1467 |
#' Crameri, F., Shephard, G. E. & Heron, P. J. (2020). The misuse of colour in |
|
| 1468 |
#' science communication. *Nature Communications*, 11, 5444. |
|
| 1469 |
#' \doi{10.1038/s41467-020-19160-7}
|
|
| 1470 |
#' @source |
|
| 1471 |
#' Crameri, F. (2023). Scientific colour maps. *Zenodo*, v8.0.1. |
|
| 1472 |
#' \doi{10.5281/zenodo.1243862}
|
|
| 1473 |
#' @example inst/examples/ex-crameri-sequential.R |
|
| 1474 |
#' @author N. Frerebeau |
|
| 1475 |
#' @family sequential color schemes |
|
| 1476 |
#' @family Fabio Crameri's color schemes |
|
| 1477 |
#' @name scale_crameri_bilbao |
|
| 1478 |
#' @rdname scale_crameri_bilbao |
|
| 1479 |
NULL |
|
| 1480 | ||
| 1481 |
#' @export |
|
| 1482 |
#' @rdname scale_crameri_bilbao |
|
| 1483 |
scale_colour_bilbao <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1484 |
discrete = FALSE, aesthetics = "colour") {
|
|
| 1485 | 5x |
if (discrete) {
|
| 1486 | 1x |
scale_discrete(aesthetics, "bilbao", reverse = reverse, ...) |
| 1487 |
} else {
|
|
| 1488 | 4x |
scale_continuous(aesthetics, "bilbao", reverse = reverse, |
| 1489 | 4x |
range = range, ...) |
| 1490 |
} |
|
| 1491 |
} |
|
| 1492 | ||
| 1493 |
#' @export |
|
| 1494 |
#' @rdname scale_crameri_bilbao |
|
| 1495 |
scale_color_bilbao <- scale_colour_bilbao |
|
| 1496 | ||
| 1497 |
#' @export |
|
| 1498 |
#' @rdname scale_crameri_bilbao |
|
| 1499 |
scale_fill_bilbao <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1500 |
discrete = FALSE, aesthetics = "fill") {
|
|
| 1501 | 3x |
if (discrete) {
|
| 1502 | 1x |
scale_discrete(aesthetics, "bilbao", reverse = reverse, ...) |
| 1503 |
} else {
|
|
| 1504 | 2x |
scale_continuous(aesthetics, "bilbao", reverse = reverse, |
| 1505 | 2x |
range = range, ...) |
| 1506 |
} |
|
| 1507 |
} |
|
| 1508 | ||
| 1509 |
#' @export |
|
| 1510 |
#' @rdname scale_crameri_bilbao |
|
| 1511 |
scale_edge_colour_bilbao <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1512 |
discrete = FALSE, |
|
| 1513 |
aesthetics = "edge_colour") {
|
|
| 1514 | 5x |
if (discrete) {
|
| 1515 | 1x |
scale_discrete(aesthetics, "bilbao", reverse = reverse, ...) |
| 1516 |
} else {
|
|
| 1517 | 4x |
scale_continuous(aesthetics, "bilbao", guide = "edge_colourbar", |
| 1518 | 4x |
reverse = reverse, range = range, ...) |
| 1519 |
} |
|
| 1520 |
} |
|
| 1521 | ||
| 1522 |
#' @export |
|
| 1523 |
#' @rdname scale_crameri_bilbao |
|
| 1524 |
scale_edge_color_bilbao <- scale_edge_colour_bilbao |
|
| 1525 | ||
| 1526 |
#' @export |
|
| 1527 |
#' @rdname scale_crameri_bilbao |
|
| 1528 |
scale_edge_fill_bilbao <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1529 |
discrete = FALSE, |
|
| 1530 |
aesthetics = "edge_fill") {
|
|
| 1531 | 3x |
if (discrete) {
|
| 1532 | 1x |
scale_discrete(aesthetics, "bilbao", reverse = reverse, ...) |
| 1533 |
} else {
|
|
| 1534 | 2x |
scale_continuous(aesthetics, "bilbao", guide = "edge_colourbar", |
| 1535 | 2x |
reverse = reverse, range = range, ...) |
| 1536 |
} |
|
| 1537 |
} |
|
| 1538 | ||
| 1539 |
## nuuk ------------------------------------------------------------------------ |
|
| 1540 |
#' Fabio Crameri's *nuuk* Sequential Color Scheme |
|
| 1541 |
#' |
|
| 1542 |
#' @inheritParams scale_crameri_batlow |
|
| 1543 |
#' @inheritSection crameri Sequential Color Schemes |
|
| 1544 |
#' @return A [continuous][ggplot2::continuous_scale] scale. |
|
| 1545 |
#' @references |
|
| 1546 |
#' Crameri, F. (2018). Geodynamic diagnostics, scientific visualisation and |
|
| 1547 |
#' StagLab 3.0. *Geosci. Model Dev.*, 11, 2541-2562. |
|
| 1548 |
#' \doi{10.5194/gmd-11-2541-2018}
|
|
| 1549 |
#' |
|
| 1550 |
#' Crameri, F., Shephard, G. E. & Heron, P. J. (2020). The misuse of colour in |
|
| 1551 |
#' science communication. *Nature Communications*, 11, 5444. |
|
| 1552 |
#' \doi{10.1038/s41467-020-19160-7}
|
|
| 1553 |
#' @source |
|
| 1554 |
#' Crameri, F. (2023). Scientific colour maps. *Zenodo*, v8.0.1. |
|
| 1555 |
#' \doi{10.5281/zenodo.1243862}
|
|
| 1556 |
#' @example inst/examples/ex-crameri-sequential.R |
|
| 1557 |
#' @author N. Frerebeau |
|
| 1558 |
#' @family sequential color schemes |
|
| 1559 |
#' @family Fabio Crameri's color schemes |
|
| 1560 |
#' @name scale_crameri_nuuk |
|
| 1561 |
#' @rdname scale_crameri_nuuk |
|
| 1562 |
NULL |
|
| 1563 | ||
| 1564 |
#' @export |
|
| 1565 |
#' @rdname scale_crameri_nuuk |
|
| 1566 |
scale_colour_nuuk <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1567 |
discrete = FALSE, aesthetics = "colour") {
|
|
| 1568 | 5x |
if (discrete) {
|
| 1569 | 1x |
scale_discrete(aesthetics, "nuuk", reverse = reverse, ...) |
| 1570 |
} else {
|
|
| 1571 | 4x |
scale_continuous(aesthetics, "nuuk", reverse = reverse, |
| 1572 | 4x |
range = range, ...) |
| 1573 |
} |
|
| 1574 |
} |
|
| 1575 | ||
| 1576 |
#' @export |
|
| 1577 |
#' @rdname scale_crameri_nuuk |
|
| 1578 |
scale_color_nuuk <- scale_colour_nuuk |
|
| 1579 | ||
| 1580 |
#' @export |
|
| 1581 |
#' @rdname scale_crameri_nuuk |
|
| 1582 |
scale_fill_nuuk <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1583 |
discrete = FALSE, aesthetics = "fill") {
|
|
| 1584 | 3x |
if (discrete) {
|
| 1585 | 1x |
scale_discrete(aesthetics, "nuuk", reverse = reverse, ...) |
| 1586 |
} else {
|
|
| 1587 | 2x |
scale_continuous(aesthetics, "nuuk", reverse = reverse, |
| 1588 | 2x |
range = range, ...) |
| 1589 |
} |
|
| 1590 |
} |
|
| 1591 | ||
| 1592 |
#' @export |
|
| 1593 |
#' @rdname scale_crameri_nuuk |
|
| 1594 |
scale_edge_colour_nuuk <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1595 |
discrete = FALSE, |
|
| 1596 |
aesthetics = "edge_colour") {
|
|
| 1597 | 5x |
if (discrete) {
|
| 1598 | 1x |
scale_discrete(aesthetics, "nuuk", reverse = reverse, ...) |
| 1599 |
} else {
|
|
| 1600 | 4x |
scale_continuous(aesthetics, "nuuk", guide = "edge_colourbar", |
| 1601 | 4x |
reverse = reverse, range = range, ...) |
| 1602 |
} |
|
| 1603 |
} |
|
| 1604 | ||
| 1605 |
#' @export |
|
| 1606 |
#' @rdname scale_crameri_nuuk |
|
| 1607 |
scale_edge_color_nuuk <- scale_edge_colour_nuuk |
|
| 1608 | ||
| 1609 |
#' @export |
|
| 1610 |
#' @rdname scale_crameri_nuuk |
|
| 1611 |
scale_edge_fill_nuuk <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1612 |
discrete = FALSE, |
|
| 1613 |
aesthetics = "edge_fill") {
|
|
| 1614 | 3x |
if (discrete) {
|
| 1615 | 1x |
scale_discrete(aesthetics, "nuuk", reverse = reverse, ...) |
| 1616 |
} else {
|
|
| 1617 | 2x |
scale_continuous(aesthetics, "nuuk", guide = "edge_colourbar", |
| 1618 | 2x |
reverse = reverse, range = range, ...) |
| 1619 |
} |
|
| 1620 |
} |
|
| 1621 | ||
| 1622 |
## oslo ------------------------------------------------------------------------ |
|
| 1623 |
#' Fabio Crameri's *oslo* Sequential Color Scheme |
|
| 1624 |
#' |
|
| 1625 |
#' @inheritParams scale_crameri_batlow |
|
| 1626 |
#' @inheritSection crameri Sequential Color Schemes |
|
| 1627 |
#' @return A [continuous][ggplot2::continuous_scale] scale. |
|
| 1628 |
#' @references |
|
| 1629 |
#' Crameri, F. (2018). Geodynamic diagnostics, scientific visualisation and |
|
| 1630 |
#' StagLab 3.0. *Geosci. Model Dev.*, 11, 2541-2562. |
|
| 1631 |
#' \doi{10.5194/gmd-11-2541-2018}
|
|
| 1632 |
#' |
|
| 1633 |
#' Crameri, F., Shephard, G. E. & Heron, P. J. (2020). The misuse of colour in |
|
| 1634 |
#' science communication. *Nature Communications*, 11, 5444. |
|
| 1635 |
#' \doi{10.1038/s41467-020-19160-7}
|
|
| 1636 |
#' @source |
|
| 1637 |
#' Crameri, F. (2023). Scientific colour maps. *Zenodo*, v8.0.1. |
|
| 1638 |
#' \doi{10.5281/zenodo.1243862}
|
|
| 1639 |
#' @example inst/examples/ex-crameri-sequential.R |
|
| 1640 |
#' @author N. Frerebeau |
|
| 1641 |
#' @family sequential color schemes |
|
| 1642 |
#' @family Fabio Crameri's color schemes |
|
| 1643 |
#' @name scale_crameri_oslo |
|
| 1644 |
#' @rdname scale_crameri_oslo |
|
| 1645 |
NULL |
|
| 1646 | ||
| 1647 |
#' @export |
|
| 1648 |
#' @rdname scale_crameri_oslo |
|
| 1649 |
scale_colour_oslo <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1650 |
discrete = FALSE, aesthetics = "colour") {
|
|
| 1651 | 5x |
if (discrete) {
|
| 1652 | 1x |
scale_discrete(aesthetics, "oslo", reverse = reverse, ...) |
| 1653 |
} else {
|
|
| 1654 | 4x |
scale_continuous(aesthetics, "oslo", reverse = reverse, |
| 1655 | 4x |
range = range, ...) |
| 1656 |
} |
|
| 1657 |
} |
|
| 1658 | ||
| 1659 |
#' @export |
|
| 1660 |
#' @rdname scale_crameri_oslo |
|
| 1661 |
scale_color_oslo <- scale_colour_oslo |
|
| 1662 | ||
| 1663 |
#' @export |
|
| 1664 |
#' @rdname scale_crameri_oslo |
|
| 1665 |
scale_fill_oslo <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1666 |
discrete = FALSE, aesthetics = "fill") {
|
|
| 1667 | 3x |
if (discrete) {
|
| 1668 | 1x |
scale_discrete(aesthetics, "oslo", reverse = reverse, ...) |
| 1669 |
} else {
|
|
| 1670 | 2x |
scale_continuous(aesthetics, "oslo", reverse = reverse, |
| 1671 | 2x |
range = range, ...) |
| 1672 |
} |
|
| 1673 |
} |
|
| 1674 | ||
| 1675 |
#' @export |
|
| 1676 |
#' @rdname scale_crameri_oslo |
|
| 1677 |
scale_edge_colour_oslo <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1678 |
discrete = FALSE, |
|
| 1679 |
aesthetics = "edge_colour") {
|
|
| 1680 | 5x |
if (discrete) {
|
| 1681 | 1x |
scale_discrete(aesthetics, "oslo", reverse = reverse, ...) |
| 1682 |
} else {
|
|
| 1683 | 4x |
scale_continuous(aesthetics, "oslo", guide = "edge_colourbar", |
| 1684 | 4x |
reverse = reverse, range = range, ...) |
| 1685 |
} |
|
| 1686 |
} |
|
| 1687 | ||
| 1688 |
#' @export |
|
| 1689 |
#' @rdname scale_crameri_oslo |
|
| 1690 |
scale_edge_color_oslo <- scale_edge_colour_oslo |
|
| 1691 | ||
| 1692 |
#' @export |
|
| 1693 |
#' @rdname scale_crameri_oslo |
|
| 1694 |
scale_edge_fill_oslo <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1695 |
discrete = FALSE, |
|
| 1696 |
aesthetics = "edge_fill") {
|
|
| 1697 | 3x |
if (discrete) {
|
| 1698 | 1x |
scale_discrete(aesthetics, "oslo", reverse = reverse, ...) |
| 1699 |
} else {
|
|
| 1700 | 2x |
scale_continuous(aesthetics, "oslo", guide = "edge_colourbar", |
| 1701 | 2x |
reverse = reverse, range = range, ...) |
| 1702 |
} |
|
| 1703 |
} |
|
| 1704 | ||
| 1705 |
## grayC ----------------------------------------------------------------------- |
|
| 1706 |
#' Fabio Crameri's *grayC* Sequential Color Scheme |
|
| 1707 |
#' |
|
| 1708 |
#' @inheritParams scale_crameri_batlow |
|
| 1709 |
#' @inheritSection crameri Sequential Color Schemes |
|
| 1710 |
#' @return A [continuous][ggplot2::continuous_scale] scale. |
|
| 1711 |
#' @references |
|
| 1712 |
#' Crameri, F. (2018). Geodynamic diagnostics, scientific visualisation and |
|
| 1713 |
#' StagLab 3.0. *Geosci. Model Dev.*, 11, 2541-2562. |
|
| 1714 |
#' \doi{10.5194/gmd-11-2541-2018}
|
|
| 1715 |
#' |
|
| 1716 |
#' Crameri, F., Shephard, G. E. & Heron, P. J. (2020). The misuse of colour in |
|
| 1717 |
#' science communication. *Nature Communications*, 11, 5444. |
|
| 1718 |
#' \doi{10.1038/s41467-020-19160-7}
|
|
| 1719 |
#' @source |
|
| 1720 |
#' Crameri, F. (2023). Scientific colour maps. *Zenodo*, v8.0.1. |
|
| 1721 |
#' \doi{10.5281/zenodo.1243862}
|
|
| 1722 |
#' @example inst/examples/ex-crameri-sequential.R |
|
| 1723 |
#' @author N. Frerebeau |
|
| 1724 |
#' @family sequential color schemes |
|
| 1725 |
#' @family Fabio Crameri's color schemes |
|
| 1726 |
#' @name scale_crameri_grayC |
|
| 1727 |
#' @rdname scale_crameri_grayC |
|
| 1728 |
NULL |
|
| 1729 | ||
| 1730 |
#' @export |
|
| 1731 |
#' @rdname scale_crameri_grayC |
|
| 1732 |
scale_colour_grayC <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1733 |
discrete = FALSE, aesthetics = "colour") {
|
|
| 1734 | 5x |
if (discrete) {
|
| 1735 | 1x |
scale_discrete(aesthetics, "grayC", reverse = reverse, ...) |
| 1736 |
} else {
|
|
| 1737 | 4x |
scale_continuous(aesthetics, "grayC", reverse = reverse, |
| 1738 | 4x |
range = range, ...) |
| 1739 |
} |
|
| 1740 |
} |
|
| 1741 | ||
| 1742 |
#' @export |
|
| 1743 |
#' @rdname scale_crameri_grayC |
|
| 1744 |
scale_color_grayC <- scale_colour_grayC |
|
| 1745 | ||
| 1746 |
#' @export |
|
| 1747 |
#' @rdname scale_crameri_grayC |
|
| 1748 |
scale_fill_grayC <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1749 |
discrete = FALSE, aesthetics = "fill") {
|
|
| 1750 | 3x |
if (discrete) {
|
| 1751 | 1x |
scale_discrete(aesthetics, "grayC", reverse = reverse, ...) |
| 1752 |
} else {
|
|
| 1753 | 2x |
scale_continuous(aesthetics, "grayC", reverse = reverse, |
| 1754 | 2x |
range = range, ...) |
| 1755 |
} |
|
| 1756 |
} |
|
| 1757 | ||
| 1758 |
#' @export |
|
| 1759 |
#' @rdname scale_crameri_grayC |
|
| 1760 |
scale_edge_colour_grayC <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1761 |
discrete = FALSE, |
|
| 1762 |
aesthetics = "edge_colour") {
|
|
| 1763 | 5x |
if (discrete) {
|
| 1764 | 1x |
scale_discrete(aesthetics, "grayC", reverse = reverse, ...) |
| 1765 |
} else {
|
|
| 1766 | 4x |
scale_continuous(aesthetics, "grayC", guide = "edge_colourbar", |
| 1767 | 4x |
reverse = reverse, range = range, ...) |
| 1768 |
} |
|
| 1769 |
} |
|
| 1770 | ||
| 1771 |
#' @export |
|
| 1772 |
#' @rdname scale_crameri_grayC |
|
| 1773 |
scale_edge_color_grayC <- scale_edge_colour_grayC |
|
| 1774 | ||
| 1775 |
#' @export |
|
| 1776 |
#' @rdname scale_crameri_grayC |
|
| 1777 |
scale_edge_fill_grayC <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1778 |
discrete = FALSE, |
|
| 1779 |
aesthetics = "edge_fill") {
|
|
| 1780 | 3x |
if (discrete) {
|
| 1781 | 1x |
scale_discrete(aesthetics, "grayC", reverse = reverse, ...) |
| 1782 |
} else {
|
|
| 1783 | 2x |
scale_continuous(aesthetics, "grayC", guide = "edge_colourbar", |
| 1784 | 2x |
reverse = reverse, range = range, ...) |
| 1785 |
} |
|
| 1786 |
} |
|
| 1787 | ||
| 1788 |
## hawaii ---------------------------------------------------------------------- |
|
| 1789 |
#' Fabio Crameri's *hawaii* Sequential Color Scheme |
|
| 1790 |
#' |
|
| 1791 |
#' @inheritParams scale_crameri_batlow |
|
| 1792 |
#' @inheritSection crameri Sequential Color Schemes |
|
| 1793 |
#' @return A [continuous][ggplot2::continuous_scale] scale. |
|
| 1794 |
#' @references |
|
| 1795 |
#' Crameri, F. (2018). Geodynamic diagnostics, scientific visualisation and |
|
| 1796 |
#' StagLab 3.0. *Geosci. Model Dev.*, 11, 2541-2562. |
|
| 1797 |
#' \doi{10.5194/gmd-11-2541-2018}
|
|
| 1798 |
#' |
|
| 1799 |
#' Crameri, F., Shephard, G. E. & Heron, P. J. (2020). The misuse of colour in |
|
| 1800 |
#' science communication. *Nature Communications*, 11, 5444. |
|
| 1801 |
#' \doi{10.1038/s41467-020-19160-7}
|
|
| 1802 |
#' @source |
|
| 1803 |
#' Crameri, F. (2023). Scientific colour maps. *Zenodo*, v8.0.1. |
|
| 1804 |
#' \doi{10.5281/zenodo.1243862}
|
|
| 1805 |
#' @example inst/examples/ex-crameri-sequential.R |
|
| 1806 |
#' @author N. Frerebeau |
|
| 1807 |
#' @family sequential color schemes |
|
| 1808 |
#' @family Fabio Crameri's color schemes |
|
| 1809 |
#' @name scale_crameri_hawaii |
|
| 1810 |
#' @rdname scale_crameri_hawaii |
|
| 1811 |
NULL |
|
| 1812 | ||
| 1813 |
#' @export |
|
| 1814 |
#' @rdname scale_crameri_hawaii |
|
| 1815 |
scale_colour_hawaii <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1816 |
discrete = FALSE, aesthetics = "colour") {
|
|
| 1817 | 5x |
if (discrete) {
|
| 1818 | 1x |
scale_discrete(aesthetics, "hawaii", reverse = reverse, ...) |
| 1819 |
} else {
|
|
| 1820 | 4x |
scale_continuous(aesthetics, "hawaii", reverse = reverse, |
| 1821 | 4x |
range = range, ...) |
| 1822 |
} |
|
| 1823 |
} |
|
| 1824 | ||
| 1825 |
#' @export |
|
| 1826 |
#' @rdname scale_crameri_hawaii |
|
| 1827 |
scale_color_hawaii <- scale_colour_hawaii |
|
| 1828 | ||
| 1829 |
#' @export |
|
| 1830 |
#' @rdname scale_crameri_hawaii |
|
| 1831 |
scale_fill_hawaii <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1832 |
discrete = FALSE, aesthetics = "fill") {
|
|
| 1833 | 3x |
if (discrete) {
|
| 1834 | 1x |
scale_discrete(aesthetics, "hawaii", reverse = reverse, ...) |
| 1835 |
} else {
|
|
| 1836 | 2x |
scale_continuous(aesthetics, "hawaii", reverse = reverse, |
| 1837 | 2x |
range = range, ...) |
| 1838 |
} |
|
| 1839 |
} |
|
| 1840 | ||
| 1841 |
#' @export |
|
| 1842 |
#' @rdname scale_crameri_hawaii |
|
| 1843 |
scale_edge_colour_hawaii <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1844 |
discrete = FALSE, |
|
| 1845 |
aesthetics = "edge_colour") {
|
|
| 1846 | 5x |
if (discrete) {
|
| 1847 | 1x |
scale_discrete(aesthetics, "hawaii", reverse = reverse, ...) |
| 1848 |
} else {
|
|
| 1849 | 4x |
scale_continuous(aesthetics, "hawaii", guide = "edge_colourbar", |
| 1850 | 4x |
reverse = reverse, range = range, ...) |
| 1851 |
} |
|
| 1852 |
} |
|
| 1853 | ||
| 1854 |
#' @export |
|
| 1855 |
#' @rdname scale_crameri_hawaii |
|
| 1856 |
scale_edge_color_hawaii <- scale_edge_colour_hawaii |
|
| 1857 | ||
| 1858 |
#' @export |
|
| 1859 |
#' @rdname scale_crameri_hawaii |
|
| 1860 |
scale_edge_fill_hawaii <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1861 |
discrete = FALSE, |
|
| 1862 |
aesthetics = "edge_fill") {
|
|
| 1863 | 3x |
if (discrete) {
|
| 1864 | 1x |
scale_discrete(aesthetics, "hawaii", reverse = reverse, ...) |
| 1865 |
} else {
|
|
| 1866 | 2x |
scale_continuous(aesthetics, "hawaii", guide = "edge_colourbar", |
| 1867 | 2x |
reverse = reverse, range = range, ...) |
| 1868 |
} |
|
| 1869 |
} |
|
| 1870 | ||
| 1871 |
## lapaz ----------------------------------------------------------------------- |
|
| 1872 |
#' Fabio Crameri's *lapaz* Sequential Color Scheme |
|
| 1873 |
#' |
|
| 1874 |
#' @inheritParams scale_crameri_batlow |
|
| 1875 |
#' @inheritSection crameri Sequential Color Schemes |
|
| 1876 |
#' @return A [continuous][ggplot2::continuous_scale] scale. |
|
| 1877 |
#' @references |
|
| 1878 |
#' Crameri, F. (2018). Geodynamic diagnostics, scientific visualisation and |
|
| 1879 |
#' StagLab 3.0. *Geosci. Model Dev.*, 11, 2541-2562. |
|
| 1880 |
#' \doi{10.5194/gmd-11-2541-2018}
|
|
| 1881 |
#' |
|
| 1882 |
#' Crameri, F., Shephard, G. E. & Heron, P. J. (2020). The misuse of colour in |
|
| 1883 |
#' science communication. *Nature Communications*, 11, 5444. |
|
| 1884 |
#' \doi{10.1038/s41467-020-19160-7}
|
|
| 1885 |
#' @source |
|
| 1886 |
#' Crameri, F. (2023). Scientific colour maps. *Zenodo*, v8.0.1. |
|
| 1887 |
#' \doi{10.5281/zenodo.1243862}
|
|
| 1888 |
#' @example inst/examples/ex-crameri-sequential.R |
|
| 1889 |
#' @author N. Frerebeau |
|
| 1890 |
#' @family sequential color schemes |
|
| 1891 |
#' @family Fabio Crameri's color schemes |
|
| 1892 |
#' @name scale_crameri_lapaz |
|
| 1893 |
#' @rdname scale_crameri_lapaz |
|
| 1894 |
NULL |
|
| 1895 | ||
| 1896 |
#' @export |
|
| 1897 |
#' @rdname scale_crameri_lapaz |
|
| 1898 |
scale_colour_lapaz <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1899 |
discrete = FALSE, aesthetics = "colour") {
|
|
| 1900 | 5x |
if (discrete) {
|
| 1901 | 1x |
scale_discrete(aesthetics, "lapaz", reverse = reverse, ...) |
| 1902 |
} else {
|
|
| 1903 | 4x |
scale_continuous(aesthetics, "lapaz", reverse = reverse, |
| 1904 | 4x |
range = range, ...) |
| 1905 |
} |
|
| 1906 |
} |
|
| 1907 | ||
| 1908 |
#' @export |
|
| 1909 |
#' @rdname scale_crameri_lapaz |
|
| 1910 |
scale_color_lapaz <- scale_colour_lapaz |
|
| 1911 | ||
| 1912 |
#' @export |
|
| 1913 |
#' @rdname scale_crameri_lapaz |
|
| 1914 |
scale_fill_lapaz <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1915 |
discrete = FALSE, aesthetics = "fill") {
|
|
| 1916 | 3x |
if (discrete) {
|
| 1917 | 1x |
scale_discrete(aesthetics, "lapaz", reverse = reverse, ...) |
| 1918 |
} else {
|
|
| 1919 | 2x |
scale_continuous(aesthetics, "lapaz", reverse = reverse, |
| 1920 | 2x |
range = range, ...) |
| 1921 |
} |
|
| 1922 |
} |
|
| 1923 | ||
| 1924 |
#' @export |
|
| 1925 |
#' @rdname scale_crameri_lapaz |
|
| 1926 |
scale_edge_colour_lapaz <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1927 |
discrete = FALSE, |
|
| 1928 |
aesthetics = "edge_colour") {
|
|
| 1929 | 5x |
if (discrete) {
|
| 1930 | 1x |
scale_discrete(aesthetics, "lapaz", reverse = reverse, ...) |
| 1931 |
} else {
|
|
| 1932 | 4x |
scale_continuous(aesthetics, "lapaz", guide = "edge_colourbar", |
| 1933 | 4x |
reverse = reverse, range = range, ...) |
| 1934 |
} |
|
| 1935 |
} |
|
| 1936 | ||
| 1937 |
#' @export |
|
| 1938 |
#' @rdname scale_crameri_lapaz |
|
| 1939 |
scale_edge_color_lapaz <- scale_edge_colour_lapaz |
|
| 1940 | ||
| 1941 |
#' @export |
|
| 1942 |
#' @rdname scale_crameri_lapaz |
|
| 1943 |
scale_edge_fill_lapaz <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1944 |
discrete = FALSE, |
|
| 1945 |
aesthetics = "edge_fill") {
|
|
| 1946 | 3x |
if (discrete) {
|
| 1947 | 1x |
scale_discrete(aesthetics, "lapaz", reverse = reverse, ...) |
| 1948 |
} else {
|
|
| 1949 | 2x |
scale_continuous(aesthetics, "lapaz", guide = "edge_colourbar", |
| 1950 | 2x |
reverse = reverse, range = range, ...) |
| 1951 |
} |
|
| 1952 |
} |
|
| 1953 | ||
| 1954 |
## tokyo ----------------------------------------------------------------------- |
|
| 1955 |
#' Fabio Crameri's *tokyo* Sequential Color Scheme |
|
| 1956 |
#' |
|
| 1957 |
#' @inheritParams scale_crameri_batlow |
|
| 1958 |
#' @inheritSection crameri Sequential Color Schemes |
|
| 1959 |
#' @return A [continuous][ggplot2::continuous_scale] scale. |
|
| 1960 |
#' @references |
|
| 1961 |
#' Crameri, F. (2018). Geodynamic diagnostics, scientific visualisation and |
|
| 1962 |
#' StagLab 3.0. *Geosci. Model Dev.*, 11, 2541-2562. |
|
| 1963 |
#' \doi{10.5194/gmd-11-2541-2018}
|
|
| 1964 |
#' |
|
| 1965 |
#' Crameri, F., Shephard, G. E. & Heron, P. J. (2020). The misuse of colour in |
|
| 1966 |
#' science communication. *Nature Communications*, 11, 5444. |
|
| 1967 |
#' \doi{10.1038/s41467-020-19160-7}
|
|
| 1968 |
#' @source |
|
| 1969 |
#' Crameri, F. (2023). Scientific colour maps. *Zenodo*, v8.0.1. |
|
| 1970 |
#' \doi{10.5281/zenodo.1243862}
|
|
| 1971 |
#' @example inst/examples/ex-crameri-sequential.R |
|
| 1972 |
#' @author N. Frerebeau |
|
| 1973 |
#' @family sequential color schemes |
|
| 1974 |
#' @family Fabio Crameri's color schemes |
|
| 1975 |
#' @name scale_crameri_tokyo |
|
| 1976 |
#' @rdname scale_crameri_tokyo |
|
| 1977 |
NULL |
|
| 1978 | ||
| 1979 |
#' @export |
|
| 1980 |
#' @rdname scale_crameri_tokyo |
|
| 1981 |
scale_colour_tokyo <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1982 |
discrete = FALSE, aesthetics = "colour") {
|
|
| 1983 | 5x |
if (discrete) {
|
| 1984 | 1x |
scale_discrete(aesthetics, "tokyo", reverse = reverse, ...) |
| 1985 |
} else {
|
|
| 1986 | 4x |
scale_continuous(aesthetics, "tokyo", reverse = reverse, |
| 1987 | 4x |
range = range, ...) |
| 1988 |
} |
|
| 1989 |
} |
|
| 1990 | ||
| 1991 |
#' @export |
|
| 1992 |
#' @rdname scale_crameri_tokyo |
|
| 1993 |
scale_color_tokyo <- scale_colour_tokyo |
|
| 1994 | ||
| 1995 |
#' @export |
|
| 1996 |
#' @rdname scale_crameri_tokyo |
|
| 1997 |
scale_fill_tokyo <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 1998 |
discrete = FALSE, aesthetics = "fill") {
|
|
| 1999 | 3x |
if (discrete) {
|
| 2000 | 1x |
scale_discrete(aesthetics, "tokyo", reverse = reverse, ...) |
| 2001 |
} else {
|
|
| 2002 | 2x |
scale_continuous(aesthetics, "tokyo", reverse = reverse, |
| 2003 | 2x |
range = range, ...) |
| 2004 |
} |
|
| 2005 |
} |
|
| 2006 | ||
| 2007 |
#' @export |
|
| 2008 |
#' @rdname scale_crameri_tokyo |
|
| 2009 |
scale_edge_colour_tokyo <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 2010 |
discrete = FALSE, |
|
| 2011 |
aesthetics = "edge_colour") {
|
|
| 2012 | 5x |
if (discrete) {
|
| 2013 | 1x |
scale_discrete(aesthetics, "tokyo", reverse = reverse, ...) |
| 2014 |
} else {
|
|
| 2015 | 4x |
scale_continuous(aesthetics, "tokyo", guide = "edge_colourbar", |
| 2016 | 4x |
reverse = reverse, range = range, ...) |
| 2017 |
} |
|
| 2018 |
} |
|
| 2019 | ||
| 2020 |
#' @export |
|
| 2021 |
#' @rdname scale_crameri_tokyo |
|
| 2022 |
scale_edge_color_tokyo <- scale_edge_colour_tokyo |
|
| 2023 | ||
| 2024 |
#' @export |
|
| 2025 |
#' @rdname scale_crameri_tokyo |
|
| 2026 |
scale_edge_fill_tokyo <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 2027 |
discrete = FALSE, |
|
| 2028 |
aesthetics = "edge_fill") {
|
|
| 2029 | 3x |
if (discrete) {
|
| 2030 | 1x |
scale_discrete(aesthetics, "tokyo", reverse = reverse, ...) |
| 2031 |
} else {
|
|
| 2032 | 2x |
scale_continuous(aesthetics, "tokyo", guide = "edge_colourbar", |
| 2033 | 2x |
reverse = reverse, range = range, ...) |
| 2034 |
} |
|
| 2035 |
} |
|
| 2036 | ||
| 2037 |
## buda ------------------------------------------------------------------------ |
|
| 2038 |
#' Fabio Crameri's *buda* Sequential Color Scheme |
|
| 2039 |
#' |
|
| 2040 |
#' @inheritParams scale_crameri_batlow |
|
| 2041 |
#' @inheritSection crameri Sequential Color Schemes |
|
| 2042 |
#' @return A [continuous][ggplot2::continuous_scale] scale. |
|
| 2043 |
#' @references |
|
| 2044 |
#' Crameri, F. (2018). Geodynamic diagnostics, scientific visualisation and |
|
| 2045 |
#' StagLab 3.0. *Geosci. Model Dev.*, 11, 2541-2562. |
|
| 2046 |
#' \doi{10.5194/gmd-11-2541-2018}
|
|
| 2047 |
#' |
|
| 2048 |
#' Crameri, F., Shephard, G. E. & Heron, P. J. (2020). The misuse of colour in |
|
| 2049 |
#' science communication. *Nature Communications*, 11, 5444. |
|
| 2050 |
#' \doi{10.1038/s41467-020-19160-7}
|
|
| 2051 |
#' @source |
|
| 2052 |
#' Crameri, F. (2023). Scientific colour maps. *Zenodo*, v8.0.1. |
|
| 2053 |
#' \doi{10.5281/zenodo.1243862}
|
|
| 2054 |
#' @example inst/examples/ex-crameri-sequential.R |
|
| 2055 |
#' @author N. Frerebeau |
|
| 2056 |
#' @family sequential color schemes |
|
| 2057 |
#' @family Fabio Crameri's color schemes |
|
| 2058 |
#' @name scale_crameri_buda |
|
| 2059 |
#' @rdname scale_crameri_buda |
|
| 2060 |
NULL |
|
| 2061 | ||
| 2062 |
#' @export |
|
| 2063 |
#' @rdname scale_crameri_buda |
|
| 2064 |
scale_colour_buda <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 2065 |
discrete = FALSE, aesthetics = "colour") {
|
|
| 2066 | 5x |
if (discrete) {
|
| 2067 | 1x |
scale_discrete(aesthetics, "buda", reverse = reverse, ...) |
| 2068 |
} else {
|
|
| 2069 | 4x |
scale_continuous(aesthetics, "buda", reverse = reverse, |
| 2070 | 4x |
range = range, ...) |
| 2071 |
} |
|
| 2072 |
} |
|
| 2073 | ||
| 2074 |
#' @export |
|
| 2075 |
#' @rdname scale_crameri_buda |
|
| 2076 |
scale_color_buda <- scale_colour_buda |
|
| 2077 | ||
| 2078 |
#' @export |
|
| 2079 |
#' @rdname scale_crameri_buda |
|
| 2080 |
scale_fill_buda <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 2081 |
discrete = FALSE, aesthetics = "fill") {
|
|
| 2082 | 3x |
if (discrete) {
|
| 2083 | 1x |
scale_discrete(aesthetics, "buda", reverse = reverse, ...) |
| 2084 |
} else {
|
|
| 2085 | 2x |
scale_continuous(aesthetics, "buda", reverse = reverse, |
| 2086 | 2x |
range = range, ...) |
| 2087 |
} |
|
| 2088 |
} |
|
| 2089 | ||
| 2090 |
#' @export |
|
| 2091 |
#' @rdname scale_crameri_buda |
|
| 2092 |
scale_edge_colour_buda <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 2093 |
discrete = FALSE, |
|
| 2094 |
aesthetics = "edge_colour") {
|
|
| 2095 | 5x |
if (discrete) {
|
| 2096 | 1x |
scale_discrete(aesthetics, "buda", reverse = reverse, ...) |
| 2097 |
} else {
|
|
| 2098 | 4x |
scale_continuous(aesthetics, "buda", guide = "edge_colourbar", |
| 2099 | 4x |
reverse = reverse, range = range, ...) |
| 2100 |
} |
|
| 2101 |
} |
|
| 2102 | ||
| 2103 |
#' @export |
|
| 2104 |
#' @rdname scale_crameri_buda |
|
| 2105 |
scale_edge_color_buda <- scale_edge_colour_buda |
|
| 2106 | ||
| 2107 |
#' @export |
|
| 2108 |
#' @rdname scale_crameri_buda |
|
| 2109 |
scale_edge_fill_buda <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 2110 |
discrete = FALSE, |
|
| 2111 |
aesthetics = "edge_fill") {
|
|
| 2112 | 3x |
if (discrete) {
|
| 2113 | 1x |
scale_discrete(aesthetics, "buda", reverse = reverse, ...) |
| 2114 |
} else {
|
|
| 2115 | 2x |
scale_continuous(aesthetics, "buda", guide = "edge_colourbar", |
| 2116 | 2x |
reverse = reverse, range = range, ...) |
| 2117 |
} |
|
| 2118 |
} |
|
| 2119 | ||
| 2120 |
## acton ----------------------------------------------------------------------- |
|
| 2121 |
#' Fabio Crameri's *acton* Sequential Color Scheme |
|
| 2122 |
#' |
|
| 2123 |
#' @inheritParams scale_crameri_batlow |
|
| 2124 |
#' @inheritSection crameri Sequential Color Schemes |
|
| 2125 |
#' @return A [continuous][ggplot2::continuous_scale] scale. |
|
| 2126 |
#' @references |
|
| 2127 |
#' Crameri, F. (2018). Geodynamic diagnostics, scientific visualisation and |
|
| 2128 |
#' StagLab 3.0. *Geosci. Model Dev.*, 11, 2541-2562. |
|
| 2129 |
#' \doi{10.5194/gmd-11-2541-2018}
|
|
| 2130 |
#' |
|
| 2131 |
#' Crameri, F., Shephard, G. E. & Heron, P. J. (2020). The misuse of colour in |
|
| 2132 |
#' science communication. *Nature Communications*, 11, 5444. |
|
| 2133 |
#' \doi{10.1038/s41467-020-19160-7}
|
|
| 2134 |
#' @source |
|
| 2135 |
#' Crameri, F. (2023). Scientific colour maps. *Zenodo*, v8.0.1. |
|
| 2136 |
#' \doi{10.5281/zenodo.1243862}
|
|
| 2137 |
#' @example inst/examples/ex-crameri-sequential.R |
|
| 2138 |
#' @author N. Frerebeau |
|
| 2139 |
#' @family sequential color schemes |
|
| 2140 |
#' @family Fabio Crameri's color schemes |
|
| 2141 |
#' @name scale_crameri_acton |
|
| 2142 |
#' @rdname scale_crameri_acton |
|
| 2143 |
NULL |
|
| 2144 | ||
| 2145 |
#' @export |
|
| 2146 |
#' @rdname scale_crameri_acton |
|
| 2147 |
scale_colour_acton <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 2148 |
discrete = FALSE, aesthetics = "colour") {
|
|
| 2149 | 5x |
if (discrete) {
|
| 2150 | 1x |
scale_discrete(aesthetics, "acton", reverse = reverse, ...) |
| 2151 |
} else {
|
|
| 2152 | 4x |
scale_continuous(aesthetics, "acton", reverse = reverse, |
| 2153 | 4x |
range = range, ...) |
| 2154 |
} |
|
| 2155 |
} |
|
| 2156 | ||
| 2157 |
#' @export |
|
| 2158 |
#' @rdname scale_crameri_acton |
|
| 2159 |
scale_color_acton <- scale_colour_acton |
|
| 2160 | ||
| 2161 |
#' @export |
|
| 2162 |
#' @rdname scale_crameri_acton |
|
| 2163 |
scale_fill_acton <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 2164 |
discrete = FALSE, aesthetics = "fill") {
|
|
| 2165 | 3x |
if (discrete) {
|
| 2166 | 1x |
scale_discrete(aesthetics, "acton", reverse = reverse, ...) |
| 2167 |
} else {
|
|
| 2168 | 2x |
scale_continuous(aesthetics, "acton", reverse = reverse, |
| 2169 | 2x |
range = range, ...) |
| 2170 |
} |
|
| 2171 |
} |
|
| 2172 | ||
| 2173 |
#' @export |
|
| 2174 |
#' @rdname scale_crameri_acton |
|
| 2175 |
scale_edge_colour_acton <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 2176 |
discrete = FALSE, |
|
| 2177 |
aesthetics = "edge_colour") {
|
|
| 2178 | 5x |
if (discrete) {
|
| 2179 | 1x |
scale_discrete(aesthetics, "acton", reverse = reverse, ...) |
| 2180 |
} else {
|
|
| 2181 | 4x |
scale_continuous(aesthetics, "acton", guide = "edge_colourbar", |
| 2182 | 4x |
reverse = reverse, range = range, ...) |
| 2183 |
} |
|
| 2184 |
} |
|
| 2185 | ||
| 2186 |
#' @export |
|
| 2187 |
#' @rdname scale_crameri_acton |
|
| 2188 |
scale_edge_color_acton <- scale_edge_colour_acton |
|
| 2189 | ||
| 2190 |
#' @export |
|
| 2191 |
#' @rdname scale_crameri_acton |
|
| 2192 |
scale_edge_fill_acton <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 2193 |
discrete = FALSE, |
|
| 2194 |
aesthetics = "edge_fill") {
|
|
| 2195 | 3x |
if (discrete) {
|
| 2196 | 1x |
scale_discrete(aesthetics, "acton", reverse = reverse, ...) |
| 2197 |
} else {
|
|
| 2198 | 2x |
scale_continuous(aesthetics, "acton", guide = "edge_colourbar", |
| 2199 | 2x |
reverse = reverse, range = range, ...) |
| 2200 |
} |
|
| 2201 |
} |
|
| 2202 | ||
| 2203 |
## turku ----------------------------------------------------------------------- |
|
| 2204 |
#' Fabio Crameri's *turku* Sequential Color Scheme |
|
| 2205 |
#' |
|
| 2206 |
#' @inheritParams scale_crameri_batlow |
|
| 2207 |
#' @inheritSection crameri Sequential Color Schemes |
|
| 2208 |
#' @return A [continuous][ggplot2::continuous_scale] scale. |
|
| 2209 |
#' @references |
|
| 2210 |
#' Crameri, F. (2018). Geodynamic diagnostics, scientific visualisation and |
|
| 2211 |
#' StagLab 3.0. *Geosci. Model Dev.*, 11, 2541-2562. |
|
| 2212 |
#' \doi{10.5194/gmd-11-2541-2018}
|
|
| 2213 |
#' |
|
| 2214 |
#' Crameri, F., Shephard, G. E. & Heron, P. J. (2020). The misuse of colour in |
|
| 2215 |
#' science communication. *Nature Communications*, 11, 5444. |
|
| 2216 |
#' \doi{10.1038/s41467-020-19160-7}
|
|
| 2217 |
#' @source |
|
| 2218 |
#' Crameri, F. (2023). Scientific colour maps. *Zenodo*, v8.0.1. |
|
| 2219 |
#' \doi{10.5281/zenodo.1243862}
|
|
| 2220 |
#' @example inst/examples/ex-crameri-sequential.R |
|
| 2221 |
#' @author N. Frerebeau |
|
| 2222 |
#' @family sequential color schemes |
|
| 2223 |
#' @family Fabio Crameri's color schemes |
|
| 2224 |
#' @name scale_crameri_turku |
|
| 2225 |
#' @rdname scale_crameri_turku |
|
| 2226 |
NULL |
|
| 2227 | ||
| 2228 |
#' @export |
|
| 2229 |
#' @rdname scale_crameri_turku |
|
| 2230 |
scale_colour_turku <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 2231 |
discrete = FALSE, aesthetics = "colour") {
|
|
| 2232 | 5x |
if (discrete) {
|
| 2233 | 1x |
scale_discrete(aesthetics, "turku", reverse = reverse, ...) |
| 2234 |
} else {
|
|
| 2235 | 4x |
scale_continuous(aesthetics, "turku", reverse = reverse, |
| 2236 | 4x |
range = range, ...) |
| 2237 |
} |
|
| 2238 |
} |
|
| 2239 | ||
| 2240 |
#' @export |
|
| 2241 |
#' @rdname scale_crameri_turku |
|
| 2242 |
scale_color_turku <- scale_colour_turku |
|
| 2243 | ||
| 2244 |
#' @export |
|
| 2245 |
#' @rdname scale_crameri_turku |
|
| 2246 |
scale_fill_turku <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 2247 |
discrete = FALSE, aesthetics = "fill") {
|
|
| 2248 | 3x |
if (discrete) {
|
| 2249 | 1x |
scale_discrete(aesthetics, "turku", reverse = reverse, ...) |
| 2250 |
} else {
|
|
| 2251 | 2x |
scale_continuous(aesthetics, "turku", reverse = reverse, |
| 2252 | 2x |
range = range, ...) |
| 2253 |
} |
|
| 2254 |
} |
|
| 2255 | ||
| 2256 |
#' @export |
|
| 2257 |
#' @rdname scale_crameri_turku |
|
| 2258 |
scale_edge_colour_turku <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 2259 |
discrete = FALSE, |
|
| 2260 |
aesthetics = "edge_colour") {
|
|
| 2261 | 5x |
if (discrete) {
|
| 2262 | 1x |
scale_discrete(aesthetics, "turku", reverse = reverse, ...) |
| 2263 |
} else {
|
|
| 2264 | 4x |
scale_continuous(aesthetics, "turku", guide = "edge_colourbar", |
| 2265 | 4x |
reverse = reverse, range = range, ...) |
| 2266 |
} |
|
| 2267 |
} |
|
| 2268 | ||
| 2269 |
#' @export |
|
| 2270 |
#' @rdname scale_crameri_turku |
|
| 2271 |
scale_edge_color_turku <- scale_edge_colour_turku |
|
| 2272 | ||
| 2273 |
#' @export |
|
| 2274 |
#' @rdname scale_crameri_turku |
|
| 2275 |
scale_edge_fill_turku <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 2276 |
discrete = FALSE, |
|
| 2277 |
aesthetics = "edge_fill") {
|
|
| 2278 | 3x |
if (discrete) {
|
| 2279 | 1x |
scale_discrete(aesthetics, "turku", reverse = reverse, ...) |
| 2280 |
} else {
|
|
| 2281 | 2x |
scale_continuous(aesthetics, "turku", guide = "edge_colourbar", |
| 2282 | 2x |
reverse = reverse, range = range, ...) |
| 2283 |
} |
|
| 2284 |
} |
|
| 2285 | ||
| 2286 |
## imola ----------------------------------------------------------------------- |
|
| 2287 |
#' Fabio Crameri's *imola* Sequential Color Scheme |
|
| 2288 |
#' |
|
| 2289 |
#' @inheritParams scale_crameri_batlow |
|
| 2290 |
#' @inheritSection crameri Sequential Color Schemes |
|
| 2291 |
#' @return A [continuous][ggplot2::continuous_scale] scale. |
|
| 2292 |
#' @references |
|
| 2293 |
#' Crameri, F. (2018). Geodynamic diagnostics, scientific visualisation and |
|
| 2294 |
#' StagLab 3.0. *Geosci. Model Dev.*, 11, 2541-2562. |
|
| 2295 |
#' \doi{10.5194/gmd-11-2541-2018}
|
|
| 2296 |
#' |
|
| 2297 |
#' Crameri, F., Shephard, G. E. & Heron, P. J. (2020). The misuse of colour in |
|
| 2298 |
#' science communication. *Nature Communications*, 11, 5444. |
|
| 2299 |
#' \doi{10.1038/s41467-020-19160-7}
|
|
| 2300 |
#' @source |
|
| 2301 |
#' Crameri, F. (2023). Scientific colour maps. *Zenodo*, v8.0.1. |
|
| 2302 |
#' \doi{10.5281/zenodo.1243862}
|
|
| 2303 |
#' @example inst/examples/ex-crameri-sequential.R |
|
| 2304 |
#' @author N. Frerebeau |
|
| 2305 |
#' @family sequential color schemes |
|
| 2306 |
#' @family Fabio Crameri's color schemes |
|
| 2307 |
#' @name scale_crameri_imola |
|
| 2308 |
#' @rdname scale_crameri_imola |
|
| 2309 |
NULL |
|
| 2310 | ||
| 2311 |
#' @export |
|
| 2312 |
#' @rdname scale_crameri_imola |
|
| 2313 |
scale_colour_imola <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 2314 |
discrete = FALSE, aesthetics = "colour") {
|
|
| 2315 | 5x |
if (discrete) {
|
| 2316 | 1x |
scale_discrete(aesthetics, "imola", reverse = reverse, ...) |
| 2317 |
} else {
|
|
| 2318 | 4x |
scale_continuous(aesthetics, "imola", reverse = reverse, |
| 2319 | 4x |
range = range, ...) |
| 2320 |
} |
|
| 2321 |
} |
|
| 2322 | ||
| 2323 |
#' @export |
|
| 2324 |
#' @rdname scale_crameri_imola |
|
| 2325 |
scale_color_imola <- scale_colour_imola |
|
| 2326 | ||
| 2327 |
#' @export |
|
| 2328 |
#' @rdname scale_crameri_imola |
|
| 2329 |
scale_fill_imola <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 2330 |
discrete = FALSE, aesthetics = "fill") {
|
|
| 2331 | 3x |
if (discrete) {
|
| 2332 | 1x |
scale_discrete(aesthetics, "imola", reverse = reverse, ...) |
| 2333 |
} else {
|
|
| 2334 | 2x |
scale_continuous(aesthetics, "imola", reverse = reverse, |
| 2335 | 2x |
range = range, ...) |
| 2336 |
} |
|
| 2337 |
} |
|
| 2338 | ||
| 2339 |
#' @export |
|
| 2340 |
#' @rdname scale_crameri_imola |
|
| 2341 |
scale_edge_colour_imola <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 2342 |
discrete = FALSE, |
|
| 2343 |
aesthetics = "edge_colour") {
|
|
| 2344 | 5x |
if (discrete) {
|
| 2345 | 1x |
scale_discrete(aesthetics, "imola", reverse = reverse, ...) |
| 2346 |
} else {
|
|
| 2347 | 4x |
scale_continuous(aesthetics, "imola", guide = "edge_colourbar", |
| 2348 | 4x |
reverse = reverse, range = range, ...) |
| 2349 |
} |
|
| 2350 |
} |
|
| 2351 | ||
| 2352 |
#' @export |
|
| 2353 |
#' @rdname scale_crameri_imola |
|
| 2354 |
scale_edge_color_imola <- scale_edge_colour_imola |
|
| 2355 | ||
| 2356 |
#' @export |
|
| 2357 |
#' @rdname scale_crameri_imola |
|
| 2358 |
scale_edge_fill_imola <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 2359 |
discrete = FALSE, |
|
| 2360 |
aesthetics = "edge_fill") {
|
|
| 2361 | 3x |
if (discrete) {
|
| 2362 | 1x |
scale_discrete(aesthetics, "imola", reverse = reverse, ...) |
| 2363 |
} else {
|
|
| 2364 | 2x |
scale_continuous(aesthetics, "imola", guide = "edge_colourbar", |
| 2365 | 2x |
reverse = reverse, range = range, ...) |
| 2366 |
} |
|
| 2367 |
} |
|
| 2368 | ||
| 2369 |
## glasgow --------------------------------------------------------------------- |
|
| 2370 |
#' Fabio Crameri's *glasgow* Sequential Color Scheme |
|
| 2371 |
#' |
|
| 2372 |
#' @inheritParams scale_crameri_batlow |
|
| 2373 |
#' @inheritSection crameri Sequential Color Schemes |
|
| 2374 |
#' @return A [continuous][ggplot2::continuous_scale] scale. |
|
| 2375 |
#' @references |
|
| 2376 |
#' Crameri, F. (2018). Geodynamic diagnostics, scientific visualisation and |
|
| 2377 |
#' StagLab 3.0. *Geosci. Model Dev.*, 11, 2541-2562. |
|
| 2378 |
#' \doi{10.5194/gmd-11-2541-2018}
|
|
| 2379 |
#' |
|
| 2380 |
#' Crameri, F., Shephard, G. E. & Heron, P. J. (2020). The misuse of colour in |
|
| 2381 |
#' science communication. *Nature Communications*, 11, 5444. |
|
| 2382 |
#' \doi{10.1038/s41467-020-19160-7}
|
|
| 2383 |
#' @source |
|
| 2384 |
#' Crameri, F. (2023). Scientific colour maps. *Zenodo*, v8.0.1. |
|
| 2385 |
#' \doi{10.5281/zenodo.1243862}
|
|
| 2386 |
#' @example inst/examples/ex-crameri-sequential.R |
|
| 2387 |
#' @author N. Frerebeau |
|
| 2388 |
#' @family sequential color schemes |
|
| 2389 |
#' @family Fabio Crameri's color schemes |
|
| 2390 |
#' @name scale_crameri_glasgow |
|
| 2391 |
#' @rdname scale_crameri_glasgow |
|
| 2392 |
NULL |
|
| 2393 | ||
| 2394 |
#' @export |
|
| 2395 |
#' @rdname scale_crameri_glasgow |
|
| 2396 |
scale_colour_glasgow <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 2397 |
discrete = FALSE, aesthetics = "colour") {
|
|
| 2398 | 5x |
if (discrete) {
|
| 2399 | 1x |
scale_discrete(aesthetics, "glasgow", reverse = reverse, ...) |
| 2400 |
} else {
|
|
| 2401 | 4x |
scale_continuous(aesthetics, "glasgow", reverse = reverse, |
| 2402 | 4x |
range = range, ...) |
| 2403 |
} |
|
| 2404 |
} |
|
| 2405 | ||
| 2406 |
#' @export |
|
| 2407 |
#' @rdname scale_crameri_glasgow |
|
| 2408 |
scale_color_glasgow <- scale_colour_glasgow |
|
| 2409 | ||
| 2410 |
#' @export |
|
| 2411 |
#' @rdname scale_crameri_glasgow |
|
| 2412 |
scale_fill_glasgow <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 2413 |
discrete = FALSE, aesthetics = "fill") {
|
|
| 2414 | 3x |
if (discrete) {
|
| 2415 | 1x |
scale_discrete(aesthetics, "glasgow", reverse = reverse, ...) |
| 2416 |
} else {
|
|
| 2417 | 2x |
scale_continuous(aesthetics, "glasgow", reverse = reverse, |
| 2418 | 2x |
range = range, ...) |
| 2419 |
} |
|
| 2420 |
} |
|
| 2421 | ||
| 2422 |
#' @export |
|
| 2423 |
#' @rdname scale_crameri_glasgow |
|
| 2424 |
scale_edge_colour_glasgow <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 2425 |
discrete = FALSE, |
|
| 2426 |
aesthetics = "edge_colour") {
|
|
| 2427 | ! |
if (discrete) {
|
| 2428 | ! |
scale_discrete(aesthetics, "glasgow", reverse = reverse, ...) |
| 2429 |
} else {
|
|
| 2430 | ! |
scale_continuous(aesthetics, "glasgow", guide = "edge_colourbar", |
| 2431 | ! |
reverse = reverse, range = range, ...) |
| 2432 |
} |
|
| 2433 |
} |
|
| 2434 | ||
| 2435 |
#' @export |
|
| 2436 |
#' @rdname scale_crameri_glasgow |
|
| 2437 |
scale_edge_color_glasgow <- scale_edge_colour_glasgow |
|
| 2438 | ||
| 2439 |
#' @export |
|
| 2440 |
#' @rdname scale_crameri_glasgow |
|
| 2441 |
scale_edge_fill_glasgow <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 2442 |
discrete = FALSE, |
|
| 2443 |
aesthetics = "edge_fill") {
|
|
| 2444 | ! |
if (discrete) {
|
| 2445 | ! |
scale_discrete(aesthetics, "glasgow", reverse = reverse, ...) |
| 2446 |
} else {
|
|
| 2447 | ! |
scale_continuous(aesthetics, "glasgow", guide = "edge_colourbar", |
| 2448 | ! |
reverse = reverse, range = range, ...) |
| 2449 |
} |
|
| 2450 |
} |
|
| 2451 | ||
| 2452 |
## lipari ---------------------------------------------------------------------- |
|
| 2453 |
#' Fabio Crameri's *lipari* Sequential Color Scheme |
|
| 2454 |
#' |
|
| 2455 |
#' @inheritParams scale_crameri_batlow |
|
| 2456 |
#' @inheritSection crameri Sequential Color Schemes |
|
| 2457 |
#' @return A [continuous][ggplot2::continuous_scale] scale. |
|
| 2458 |
#' @references |
|
| 2459 |
#' Crameri, F. (2018). Geodynamic diagnostics, scientific visualisation and |
|
| 2460 |
#' StagLab 3.0. *Geosci. Model Dev.*, 11, 2541-2562. |
|
| 2461 |
#' \doi{10.5194/gmd-11-2541-2018}
|
|
| 2462 |
#' |
|
| 2463 |
#' Crameri, F., Shephard, G. E. & Heron, P. J. (2020). The misuse of colour in |
|
| 2464 |
#' science communication. *Nature Communications*, 11, 5444. |
|
| 2465 |
#' \doi{10.1038/s41467-020-19160-7}
|
|
| 2466 |
#' @source |
|
| 2467 |
#' Crameri, F. (2023). Scientific colour maps. *Zenodo*, v8.0.1. |
|
| 2468 |
#' \doi{10.5281/zenodo.1243862}
|
|
| 2469 |
#' @example inst/examples/ex-crameri-sequential.R |
|
| 2470 |
#' @author N. Frerebeau |
|
| 2471 |
#' @family sequential color schemes |
|
| 2472 |
#' @family Fabio Crameri's color schemes |
|
| 2473 |
#' @name scale_crameri_lipari |
|
| 2474 |
#' @rdname scale_crameri_lipari |
|
| 2475 |
NULL |
|
| 2476 | ||
| 2477 |
#' @export |
|
| 2478 |
#' @rdname scale_crameri_lipari |
|
| 2479 |
scale_colour_lipari <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 2480 |
discrete = FALSE, aesthetics = "colour") {
|
|
| 2481 | 5x |
if (discrete) {
|
| 2482 | 1x |
scale_discrete(aesthetics, "lipari", reverse = reverse, ...) |
| 2483 |
} else {
|
|
| 2484 | 4x |
scale_continuous(aesthetics, "lipari", reverse = reverse, |
| 2485 | 4x |
range = range, ...) |
| 2486 |
} |
|
| 2487 |
} |
|
| 2488 | ||
| 2489 |
#' @export |
|
| 2490 |
#' @rdname scale_crameri_lipari |
|
| 2491 |
scale_color_lipari <- scale_colour_lipari |
|
| 2492 | ||
| 2493 |
#' @export |
|
| 2494 |
#' @rdname scale_crameri_lipari |
|
| 2495 |
scale_fill_lipari <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 2496 |
discrete = FALSE, aesthetics = "fill") {
|
|
| 2497 | 3x |
if (discrete) {
|
| 2498 | 1x |
scale_discrete(aesthetics, "lipari", reverse = reverse, ...) |
| 2499 |
} else {
|
|
| 2500 | 2x |
scale_continuous(aesthetics, "lipari", reverse = reverse, |
| 2501 | 2x |
range = range, ...) |
| 2502 |
} |
|
| 2503 |
} |
|
| 2504 | ||
| 2505 |
#' @export |
|
| 2506 |
#' @rdname scale_crameri_lipari |
|
| 2507 |
scale_edge_colour_lipari <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 2508 |
discrete = FALSE, |
|
| 2509 |
aesthetics = "edge_colour") {
|
|
| 2510 | ! |
if (discrete) {
|
| 2511 | ! |
scale_discrete(aesthetics, "lipari", reverse = reverse, ...) |
| 2512 |
} else {
|
|
| 2513 | ! |
scale_continuous(aesthetics, "lipari", guide = "edge_colourbar", |
| 2514 | ! |
reverse = reverse, range = range, ...) |
| 2515 |
} |
|
| 2516 |
} |
|
| 2517 | ||
| 2518 |
#' @export |
|
| 2519 |
#' @rdname scale_crameri_lipari |
|
| 2520 |
scale_edge_color_lipari <- scale_edge_colour_lipari |
|
| 2521 | ||
| 2522 |
#' @export |
|
| 2523 |
#' @rdname scale_crameri_lipari |
|
| 2524 |
scale_edge_fill_lipari <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 2525 |
discrete = FALSE, |
|
| 2526 |
aesthetics = "edge_fill") {
|
|
| 2527 | ! |
if (discrete) {
|
| 2528 | ! |
scale_discrete(aesthetics, "lipari", reverse = reverse, ...) |
| 2529 |
} else {
|
|
| 2530 | ! |
scale_continuous(aesthetics, "lipari", guide = "edge_colourbar", |
| 2531 | ! |
reverse = reverse, range = range, ...) |
| 2532 |
} |
|
| 2533 |
} |
|
| 2534 | ||
| 2535 |
## navia ----------------------------------------------------------------------- |
|
| 2536 |
#' Fabio Crameri's *navia* Sequential Color Scheme |
|
| 2537 |
#' |
|
| 2538 |
#' @inheritParams scale_crameri_batlow |
|
| 2539 |
#' @inheritSection crameri Sequential Color Schemes |
|
| 2540 |
#' @return A [continuous][ggplot2::continuous_scale] scale. |
|
| 2541 |
#' @references |
|
| 2542 |
#' Crameri, F. (2018). Geodynamic diagnostics, scientific visualisation and |
|
| 2543 |
#' StagLab 3.0. *Geosci. Model Dev.*, 11, 2541-2562. |
|
| 2544 |
#' \doi{10.5194/gmd-11-2541-2018}
|
|
| 2545 |
#' |
|
| 2546 |
#' Crameri, F., Shephard, G. E. & Heron, P. J. (2020). The misuse of colour in |
|
| 2547 |
#' science communication. *Nature Communications*, 11, 5444. |
|
| 2548 |
#' \doi{10.1038/s41467-020-19160-7}
|
|
| 2549 |
#' @source |
|
| 2550 |
#' Crameri, F. (2023). Scientific colour maps. *Zenodo*, v8.0.1. |
|
| 2551 |
#' \doi{10.5281/zenodo.1243862}
|
|
| 2552 |
#' @example inst/examples/ex-crameri-sequential.R |
|
| 2553 |
#' @author N. Frerebeau |
|
| 2554 |
#' @family sequential color schemes |
|
| 2555 |
#' @family Fabio Crameri's color schemes |
|
| 2556 |
#' @name scale_crameri_navia |
|
| 2557 |
#' @rdname scale_crameri_navia |
|
| 2558 |
NULL |
|
| 2559 | ||
| 2560 |
#' @export |
|
| 2561 |
#' @rdname scale_crameri_navia |
|
| 2562 |
scale_colour_navia <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 2563 |
discrete = FALSE, aesthetics = "colour") {
|
|
| 2564 | 5x |
if (discrete) {
|
| 2565 | 1x |
scale_discrete(aesthetics, "navia", reverse = reverse, ...) |
| 2566 |
} else {
|
|
| 2567 | 4x |
scale_continuous(aesthetics, "navia", reverse = reverse, |
| 2568 | 4x |
range = range, ...) |
| 2569 |
} |
|
| 2570 |
} |
|
| 2571 | ||
| 2572 |
#' @export |
|
| 2573 |
#' @rdname scale_crameri_navia |
|
| 2574 |
scale_color_navia <- scale_colour_navia |
|
| 2575 | ||
| 2576 |
#' @export |
|
| 2577 |
#' @rdname scale_crameri_navia |
|
| 2578 |
scale_fill_navia <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 2579 |
discrete = FALSE, aesthetics = "fill") {
|
|
| 2580 | 3x |
if (discrete) {
|
| 2581 | 1x |
scale_discrete(aesthetics, "navia", reverse = reverse, ...) |
| 2582 |
} else {
|
|
| 2583 | 2x |
scale_continuous(aesthetics, "navia", reverse = reverse, |
| 2584 | 2x |
range = range, ...) |
| 2585 |
} |
|
| 2586 |
} |
|
| 2587 | ||
| 2588 |
#' @export |
|
| 2589 |
#' @rdname scale_crameri_navia |
|
| 2590 |
scale_edge_colour_navia <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 2591 |
discrete = FALSE, |
|
| 2592 |
aesthetics = "edge_colour") {
|
|
| 2593 | ! |
if (discrete) {
|
| 2594 | ! |
scale_discrete(aesthetics, "navia", reverse = reverse, ...) |
| 2595 |
} else {
|
|
| 2596 | ! |
scale_continuous(aesthetics, "navia", guide = "edge_colourbar", |
| 2597 | ! |
reverse = reverse, range = range, ...) |
| 2598 |
} |
|
| 2599 |
} |
|
| 2600 | ||
| 2601 |
#' @export |
|
| 2602 |
#' @rdname scale_crameri_navia |
|
| 2603 |
scale_edge_color_navia <- scale_edge_colour_navia |
|
| 2604 | ||
| 2605 |
#' @export |
|
| 2606 |
#' @rdname scale_crameri_navia |
|
| 2607 |
scale_edge_fill_navia <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 2608 |
discrete = FALSE, |
|
| 2609 |
aesthetics = "edge_fill") {
|
|
| 2610 | ! |
if (discrete) {
|
| 2611 | ! |
scale_discrete(aesthetics, "navia", reverse = reverse, ...) |
| 2612 |
} else {
|
|
| 2613 | ! |
scale_continuous(aesthetics, "navia", guide = "edge_colourbar", |
| 2614 | ! |
reverse = reverse, range = range, ...) |
| 2615 |
} |
|
| 2616 |
} |
|
| 2617 | ||
| 2618 |
## naviaW ---------------------------------------------------------------------- |
|
| 2619 |
#' Fabio Crameri's *naviaW* Sequential Color Scheme |
|
| 2620 |
#' |
|
| 2621 |
#' @inheritParams scale_crameri_batlow |
|
| 2622 |
#' @inheritSection crameri Sequential Color Schemes |
|
| 2623 |
#' @return A [continuous][ggplot2::continuous_scale] scale. |
|
| 2624 |
#' @references |
|
| 2625 |
#' Crameri, F. (2018). Geodynamic diagnostics, scientific visualisation and |
|
| 2626 |
#' StagLab 3.0. *Geosci. Model Dev.*, 11, 2541-2562. |
|
| 2627 |
#' \doi{10.5194/gmd-11-2541-2018}
|
|
| 2628 |
#' |
|
| 2629 |
#' Crameri, F., Shephard, G. E. & Heron, P. J. (2020). The misuse of colour in |
|
| 2630 |
#' science communication. *Nature Communications*, 11, 5444. |
|
| 2631 |
#' \doi{10.1038/s41467-020-19160-7}
|
|
| 2632 |
#' @source |
|
| 2633 |
#' Crameri, F. (2023). Scientific colour maps. *Zenodo*, v8.0.1. |
|
| 2634 |
#' \doi{10.5281/zenodo.1243862}
|
|
| 2635 |
#' @example inst/examples/ex-crameri-sequential.R |
|
| 2636 |
#' @author N. Frerebeau |
|
| 2637 |
#' @family sequential color schemes |
|
| 2638 |
#' @family Fabio Crameri's color schemes |
|
| 2639 |
#' @name scale_crameri_naviaW |
|
| 2640 |
#' @rdname scale_crameri_naviaW |
|
| 2641 |
NULL |
|
| 2642 | ||
| 2643 |
#' @export |
|
| 2644 |
#' @rdname scale_crameri_naviaW |
|
| 2645 |
scale_colour_naviaW <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 2646 |
discrete = FALSE, aesthetics = "colour") {
|
|
| 2647 | 5x |
if (discrete) {
|
| 2648 | 1x |
scale_discrete(aesthetics, "naviaW", reverse = reverse, ...) |
| 2649 |
} else {
|
|
| 2650 | 4x |
scale_continuous(aesthetics, "naviaW", reverse = reverse, |
| 2651 | 4x |
range = range, ...) |
| 2652 |
} |
|
| 2653 |
} |
|
| 2654 | ||
| 2655 |
#' @export |
|
| 2656 |
#' @rdname scale_crameri_naviaW |
|
| 2657 |
scale_color_naviaW <- scale_colour_naviaW |
|
| 2658 | ||
| 2659 |
#' @export |
|
| 2660 |
#' @rdname scale_crameri_naviaW |
|
| 2661 |
scale_fill_naviaW <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 2662 |
discrete = FALSE, aesthetics = "fill") {
|
|
| 2663 | 3x |
if (discrete) {
|
| 2664 | 1x |
scale_discrete(aesthetics, "naviaW", reverse = reverse, ...) |
| 2665 |
} else {
|
|
| 2666 | 2x |
scale_continuous(aesthetics, "naviaW", reverse = reverse, |
| 2667 | 2x |
range = range, ...) |
| 2668 |
} |
|
| 2669 |
} |
|
| 2670 | ||
| 2671 |
#' @export |
|
| 2672 |
#' @rdname scale_crameri_naviaW |
|
| 2673 |
scale_edge_colour_naviaW <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 2674 |
discrete = FALSE, |
|
| 2675 |
aesthetics = "edge_colour") {
|
|
| 2676 | ! |
if (discrete) {
|
| 2677 | ! |
scale_discrete(aesthetics, "naviaW", reverse = reverse, ...) |
| 2678 |
} else {
|
|
| 2679 | ! |
scale_continuous(aesthetics, "naviaW", guide = "edge_colourbar", |
| 2680 | ! |
reverse = reverse, range = range, ...) |
| 2681 |
} |
|
| 2682 |
} |
|
| 2683 | ||
| 2684 |
#' @export |
|
| 2685 |
#' @rdname scale_crameri_naviaW |
|
| 2686 |
scale_edge_color_naviaW <- scale_edge_colour_naviaW |
|
| 2687 | ||
| 2688 |
#' @export |
|
| 2689 |
#' @rdname scale_crameri_naviaW |
|
| 2690 |
scale_edge_fill_naviaW <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 2691 |
discrete = FALSE, |
|
| 2692 |
aesthetics = "edge_fill") {
|
|
| 2693 | ! |
if (discrete) {
|
| 2694 | ! |
scale_discrete(aesthetics, "naviaW", reverse = reverse, ...) |
| 2695 |
} else {
|
|
| 2696 | ! |
scale_continuous(aesthetics, "naviaW", guide = "edge_colourbar", |
| 2697 | ! |
reverse = reverse, range = range, ...) |
| 2698 |
} |
|
| 2699 |
} |
|
| 2700 | ||
| 2701 |
# Multi Sequential ============================================================= |
|
| 2702 |
## oleron ---------------------------------------------------------------------- |
|
| 2703 |
#' Fabio Crameri's *oleron* Multi-Sequential Color Scheme |
|
| 2704 |
#' |
|
| 2705 |
#' @param ... Arguments passed to [ggplot2::continuous_scale()]. |
|
| 2706 |
#' @param reverse A [`logical`] scalar. Should the resulting |
|
| 2707 |
#' vector of colors be reversed? |
|
| 2708 |
#' @param range A length-two [`numeric`] vector specifying the |
|
| 2709 |
#' fraction of the scheme's color domain to keep. |
|
| 2710 |
#' @param midpoint A length-one [`numeric`] vector giving the midpoint |
|
| 2711 |
#' (in data value) of the diverging scale. Defaults to `0`. |
|
| 2712 |
#' @param aesthetics A [`character`] string or vector of character |
|
| 2713 |
#' strings listing the name(s) of the aesthetic(s) that this scale works with. |
|
| 2714 |
#' @inheritSection crameri Sequential Color Schemes |
|
| 2715 |
#' @return A [continuous][ggplot2::continuous_scale] scale. |
|
| 2716 |
#' @references |
|
| 2717 |
#' Crameri, F. (2018). Geodynamic diagnostics, scientific visualisation and |
|
| 2718 |
#' StagLab 3.0. *Geosci. Model Dev.*, 11, 2541-2562. |
|
| 2719 |
#' \doi{10.5194/gmd-11-2541-2018}
|
|
| 2720 |
#' |
|
| 2721 |
#' Crameri, F., Shephard, G. E. & Heron, P. J. (2020). The misuse of colour in |
|
| 2722 |
#' science communication. *Nature Communications*, 11, 5444. |
|
| 2723 |
#' \doi{10.1038/s41467-020-19160-7}
|
|
| 2724 |
#' @source |
|
| 2725 |
#' Crameri, F. (2023). Scientific colour maps. *Zenodo*, v8.0.1. |
|
| 2726 |
#' \doi{10.5281/zenodo.1243862}
|
|
| 2727 |
#' @example inst/examples/ex-crameri-multisequential.R |
|
| 2728 |
#' @author N. Frerebeau |
|
| 2729 |
#' @family multi sequential color schemes |
|
| 2730 |
#' @family Fabio Crameri's color schemes |
|
| 2731 |
#' @name scale_crameri_oleron |
|
| 2732 |
#' @rdname scale_crameri_oleron |
|
| 2733 |
NULL |
|
| 2734 | ||
| 2735 |
#' @export |
|
| 2736 |
#' @rdname scale_crameri_oleron |
|
| 2737 |
scale_colour_oleron <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 2738 |
midpoint = 0, aesthetics = "colour") {
|
|
| 2739 | 6x |
scale_continuous(aesthetics, "oleron", reverse = reverse, range = range, |
| 2740 | 6x |
midpoint = midpoint, ...) |
| 2741 |
} |
|
| 2742 | ||
| 2743 |
#' @export |
|
| 2744 |
#' @rdname scale_crameri_oleron |
|
| 2745 |
scale_color_oleron <- scale_colour_oleron |
|
| 2746 | ||
| 2747 |
#' @export |
|
| 2748 |
#' @rdname scale_crameri_oleron |
|
| 2749 |
scale_fill_oleron <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 2750 |
midpoint = 0, aesthetics = "fill") {
|
|
| 2751 | 4x |
scale_continuous(aesthetics, "oleron", reverse = reverse, range = range, |
| 2752 | 4x |
midpoint = midpoint, ...) |
| 2753 |
} |
|
| 2754 | ||
| 2755 |
## bukavu ---------------------------------------------------------------------- |
|
| 2756 |
#' Fabio Crameri's *bukavu* Multi-Sequential Color Scheme |
|
| 2757 |
#' |
|
| 2758 |
#' @inheritParams scale_crameri_oleron |
|
| 2759 |
#' @inheritSection crameri Sequential Color Schemes |
|
| 2760 |
#' @return A [continuous][ggplot2::continuous_scale] scale. |
|
| 2761 |
#' @references |
|
| 2762 |
#' Crameri, F. (2018). Geodynamic diagnostics, scientific visualisation and |
|
| 2763 |
#' StagLab 3.0. *Geosci. Model Dev.*, 11, 2541-2562. |
|
| 2764 |
#' \doi{10.5194/gmd-11-2541-2018}
|
|
| 2765 |
#' |
|
| 2766 |
#' Crameri, F., Shephard, G. E. & Heron, P. J. (2020). The misuse of colour in |
|
| 2767 |
#' science communication. *Nature Communications*, 11, 5444. |
|
| 2768 |
#' \doi{10.1038/s41467-020-19160-7}
|
|
| 2769 |
#' @source |
|
| 2770 |
#' Crameri, F. (2023). Scientific colour maps. *Zenodo*, v8.0.1. |
|
| 2771 |
#' \doi{10.5281/zenodo.1243862}
|
|
| 2772 |
#' @example inst/examples/ex-crameri-multisequential.R |
|
| 2773 |
#' @author N. Frerebeau |
|
| 2774 |
#' @family multi sequential color schemes |
|
| 2775 |
#' @family Fabio Crameri's color schemes |
|
| 2776 |
#' @name scale_crameri_bukavu |
|
| 2777 |
#' @rdname scale_crameri_bukavu |
|
| 2778 |
NULL |
|
| 2779 | ||
| 2780 |
#' @export |
|
| 2781 |
#' @rdname scale_crameri_bukavu |
|
| 2782 |
scale_colour_bukavu <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 2783 |
midpoint = 0, aesthetics = "colour") {
|
|
| 2784 | 6x |
scale_continuous(aesthetics, "bukavu", reverse = reverse, range = range, |
| 2785 | 6x |
midpoint = midpoint, ...) |
| 2786 |
} |
|
| 2787 | ||
| 2788 |
#' @export |
|
| 2789 |
#' @rdname scale_crameri_bukavu |
|
| 2790 |
scale_color_bukavu <- scale_colour_bukavu |
|
| 2791 | ||
| 2792 |
#' @export |
|
| 2793 |
#' @rdname scale_crameri_bukavu |
|
| 2794 |
scale_fill_bukavu <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 2795 |
midpoint = 0, aesthetics = "fill") {
|
|
| 2796 | 4x |
scale_continuous(aesthetics, "bukavu", reverse = reverse, range = range, |
| 2797 | 4x |
midpoint = midpoint, ...) |
| 2798 |
} |
|
| 2799 | ||
| 2800 |
## fes ------------------------------------------------------------------------- |
|
| 2801 |
#' Fabio Crameri's *fes* Multi-Sequential Color Scheme |
|
| 2802 |
#' |
|
| 2803 |
#' @inheritParams scale_crameri_oleron |
|
| 2804 |
#' @inheritSection crameri Sequential Color Schemes |
|
| 2805 |
#' @return A [continuous][ggplot2::continuous_scale] scale. |
|
| 2806 |
#' @references |
|
| 2807 |
#' Crameri, F. (2018). Geodynamic diagnostics, scientific visualisation and |
|
| 2808 |
#' StagLab 3.0. *Geosci. Model Dev.*, 11, 2541-2562. |
|
| 2809 |
#' \doi{10.5194/gmd-11-2541-2018}
|
|
| 2810 |
#' |
|
| 2811 |
#' Crameri, F., Shephard, G. E. & Heron, P. J. (2020). The misuse of colour in |
|
| 2812 |
#' science communication. *Nature Communications*, 11, 5444. |
|
| 2813 |
#' \doi{10.1038/s41467-020-19160-7}
|
|
| 2814 |
#' @source |
|
| 2815 |
#' Crameri, F. (2023). Scientific colour maps. *Zenodo*, v8.0.1. |
|
| 2816 |
#' \doi{10.5281/zenodo.1243862}
|
|
| 2817 |
#' @example inst/examples/ex-crameri-multisequential.R |
|
| 2818 |
#' @author N. Frerebeau |
|
| 2819 |
#' @family multi sequential color schemes |
|
| 2820 |
#' @family Fabio Crameri's color schemes |
|
| 2821 |
#' @name scale_crameri_fes |
|
| 2822 |
#' @rdname scale_crameri_fes |
|
| 2823 |
NULL |
|
| 2824 | ||
| 2825 |
#' @export |
|
| 2826 |
#' @rdname scale_crameri_fes |
|
| 2827 |
scale_colour_fes <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 2828 |
midpoint = 0, aesthetics = "colour") {
|
|
| 2829 | 6x |
scale_continuous(aesthetics, "fes", reverse = reverse, range = range, |
| 2830 | 6x |
midpoint = midpoint, ...) |
| 2831 |
} |
|
| 2832 | ||
| 2833 |
#' @export |
|
| 2834 |
#' @rdname scale_crameri_fes |
|
| 2835 |
scale_color_fes <- scale_colour_fes |
|
| 2836 | ||
| 2837 |
#' @export |
|
| 2838 |
#' @rdname scale_crameri_fes |
|
| 2839 |
scale_fill_fes <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 2840 |
midpoint = 0, aesthetics = "fill") {
|
|
| 2841 | 4x |
scale_continuous(aesthetics, "fes", reverse = reverse, range = range, |
| 2842 | 4x |
midpoint = midpoint, ...) |
| 2843 |
} |
|
| 2844 | ||
| 2845 |
# Cyclic ======================================================================= |
|
| 2846 |
## brocO ----------------------------------------------------------------------- |
|
| 2847 |
#' Fabio Crameri's *brocO* Cyclic Color Scheme |
|
| 2848 |
#' |
|
| 2849 |
#' @param ... Arguments passed to [ggplot2::continuous_scale()]. |
|
| 2850 |
#' @param reverse A [`logical`] scalar. Should the resulting |
|
| 2851 |
#' vector of colors be reversed? |
|
| 2852 |
#' @param range A length-two [`numeric`] vector specifying the |
|
| 2853 |
#' fraction of the scheme's color domain to keep. |
|
| 2854 |
#' @param aesthetics A [`character`] string or vector of character |
|
| 2855 |
#' strings listing the name(s) of the aesthetic(s) that this scale works with. |
|
| 2856 |
#' @param discrete A [`logical`] scalar: should the color scheme be |
|
| 2857 |
#' used as a discrete scale? |
|
| 2858 |
#' @inheritSection crameri Diverging Color Schemes |
|
| 2859 |
#' @return A [continuous][ggplot2::continuous_scale] scale. |
|
| 2860 |
#' @references |
|
| 2861 |
#' Crameri, F. (2018). Geodynamic diagnostics, scientific visualisation and |
|
| 2862 |
#' StagLab 3.0. *Geosci. Model Dev.*, 11, 2541-2562. |
|
| 2863 |
#' \doi{10.5194/gmd-11-2541-2018}
|
|
| 2864 |
#' |
|
| 2865 |
#' Crameri, F., Shephard, G. E. & Heron, P. J. (2020). The misuse of colour in |
|
| 2866 |
#' science communication. *Nature Communications*, 11, 5444. |
|
| 2867 |
#' \doi{10.1038/s41467-020-19160-7}
|
|
| 2868 |
#' @source |
|
| 2869 |
#' Crameri, F. (2023). Scientific colour maps. *Zenodo*, v8.0.1. |
|
| 2870 |
#' \doi{10.5281/zenodo.1243862}
|
|
| 2871 |
#' @example inst/examples/ex-crameri-diverging.R |
|
| 2872 |
#' @author N. Frerebeau |
|
| 2873 |
#' @family cyclic color schemes |
|
| 2874 |
#' @family Fabio Crameri's color schemes |
|
| 2875 |
#' @name scale_crameri_brocO |
|
| 2876 |
#' @rdname scale_crameri_brocO |
|
| 2877 |
NULL |
|
| 2878 | ||
| 2879 |
#' @export |
|
| 2880 |
#' @rdname scale_crameri_brocO |
|
| 2881 |
scale_colour_brocO <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 2882 |
discrete = FALSE, aesthetics = "colour") {
|
|
| 2883 | 5x |
if (discrete) {
|
| 2884 | 1x |
scale_discrete(aesthetics, "brocO", reverse = reverse, ...) |
| 2885 |
} else {
|
|
| 2886 | 4x |
scale_continuous(aesthetics, "brocO", reverse = reverse, range = range, ...) |
| 2887 |
} |
|
| 2888 |
} |
|
| 2889 | ||
| 2890 |
#' @export |
|
| 2891 |
#' @rdname scale_crameri_brocO |
|
| 2892 |
scale_color_brocO <- scale_colour_brocO |
|
| 2893 | ||
| 2894 |
#' @export |
|
| 2895 |
#' @rdname scale_crameri_brocO |
|
| 2896 |
scale_fill_brocO <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 2897 |
discrete = FALSE, aesthetics = "fill") {
|
|
| 2898 | 3x |
if (discrete) {
|
| 2899 | 1x |
scale_discrete(aesthetics, "brocO", reverse = reverse, ...) |
| 2900 |
} else {
|
|
| 2901 | 2x |
scale_continuous(aesthetics, "brocO", reverse = reverse, range = range, ...) |
| 2902 |
} |
|
| 2903 |
} |
|
| 2904 | ||
| 2905 |
## corkO ----------------------------------------------------------------------- |
|
| 2906 |
#' Fabio Crameri's *corkO* Cyclic Color Scheme |
|
| 2907 |
#' |
|
| 2908 |
#' @inheritParams scale_crameri_brocO |
|
| 2909 |
#' @inheritSection crameri Diverging Color Schemes |
|
| 2910 |
#' @return A [continuous][ggplot2::continuous_scale] scale. |
|
| 2911 |
#' @references |
|
| 2912 |
#' Crameri, F. (2018). Geodynamic diagnostics, scientific visualisation and |
|
| 2913 |
#' StagLab 3.0. *Geosci. Model Dev.*, 11, 2541-2562. |
|
| 2914 |
#' \doi{10.5194/gmd-11-2541-2018}
|
|
| 2915 |
#' |
|
| 2916 |
#' Crameri, F., Shephard, G. E. & Heron, P. J. (2020). The misuse of colour in |
|
| 2917 |
#' science communication. *Nature Communications*, 11, 5444. |
|
| 2918 |
#' \doi{10.1038/s41467-020-19160-7}
|
|
| 2919 |
#' @source |
|
| 2920 |
#' Crameri, F. (2023). Scientific colour maps. *Zenodo*, v8.0.1. |
|
| 2921 |
#' \doi{10.5281/zenodo.1243862}
|
|
| 2922 |
#' @example inst/examples/ex-crameri-diverging.R |
|
| 2923 |
#' @author N. Frerebeau |
|
| 2924 |
#' @family cyclic color schemes |
|
| 2925 |
#' @family Fabio Crameri's color schemes |
|
| 2926 |
#' @name scale_crameri_corkO |
|
| 2927 |
#' @rdname scale_crameri_corkO |
|
| 2928 |
NULL |
|
| 2929 | ||
| 2930 |
#' @export |
|
| 2931 |
#' @rdname scale_crameri_corkO |
|
| 2932 |
scale_colour_corkO <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 2933 |
discrete = FALSE, aesthetics = "colour") {
|
|
| 2934 | 5x |
if (discrete) {
|
| 2935 | 1x |
scale_discrete(aesthetics, "corkO", reverse = reverse, ...) |
| 2936 |
} else {
|
|
| 2937 | 4x |
scale_continuous(aesthetics, "corkO", reverse = reverse, range = range, ...) |
| 2938 |
} |
|
| 2939 |
} |
|
| 2940 | ||
| 2941 |
#' @export |
|
| 2942 |
#' @rdname scale_crameri_corkO |
|
| 2943 |
scale_color_corkO <- scale_colour_corkO |
|
| 2944 | ||
| 2945 |
#' @export |
|
| 2946 |
#' @rdname scale_crameri_corkO |
|
| 2947 |
scale_fill_corkO <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 2948 |
discrete = FALSE, aesthetics = "fill") {
|
|
| 2949 | 3x |
if (discrete) {
|
| 2950 | 1x |
scale_discrete(aesthetics, "corkO", reverse = reverse, ...) |
| 2951 |
} else {
|
|
| 2952 | 2x |
scale_continuous(aesthetics, "corkO", reverse = reverse, range = range, ...) |
| 2953 |
} |
|
| 2954 |
} |
|
| 2955 | ||
| 2956 |
## vikO ------------------------------------------------------------------------ |
|
| 2957 |
#' Fabio Crameri's *vikO* Cyclic Color Scheme |
|
| 2958 |
#' |
|
| 2959 |
#' @inheritParams scale_crameri_brocO |
|
| 2960 |
#' @inheritSection crameri Diverging Color Schemes |
|
| 2961 |
#' @return A [continuous][ggplot2::continuous_scale] scale. |
|
| 2962 |
#' @references |
|
| 2963 |
#' Crameri, F. (2018). Geodynamic diagnostics, scientific visualisation and |
|
| 2964 |
#' StagLab 3.0. *Geosci. Model Dev.*, 11, 2541-2562. |
|
| 2965 |
#' \doi{10.5194/gmd-11-2541-2018}
|
|
| 2966 |
#' |
|
| 2967 |
#' Crameri, F., Shephard, G. E. & Heron, P. J. (2020). The misuse of colour in |
|
| 2968 |
#' science communication. *Nature Communications*, 11, 5444. |
|
| 2969 |
#' \doi{10.1038/s41467-020-19160-7}
|
|
| 2970 |
#' @source |
|
| 2971 |
#' Crameri, F. (2023). Scientific colour maps. *Zenodo*, v8.0.1. |
|
| 2972 |
#' \doi{10.5281/zenodo.1243862}
|
|
| 2973 |
#' @example inst/examples/ex-crameri-diverging.R |
|
| 2974 |
#' @author N. Frerebeau |
|
| 2975 |
#' @family cyclic color schemes |
|
| 2976 |
#' @family Fabio Crameri's color schemes |
|
| 2977 |
#' @name scale_crameri_vikO |
|
| 2978 |
#' @rdname scale_crameri_vikO |
|
| 2979 |
NULL |
|
| 2980 | ||
| 2981 |
#' @export |
|
| 2982 |
#' @rdname scale_crameri_vikO |
|
| 2983 |
scale_colour_vikO <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 2984 |
discrete = FALSE, aesthetics = "colour") {
|
|
| 2985 | 5x |
if (discrete) {
|
| 2986 | 1x |
scale_discrete(aesthetics, "vikO", reverse = reverse, ...) |
| 2987 |
} else {
|
|
| 2988 | 4x |
scale_continuous(aesthetics, "vikO", reverse = reverse, range = range, ...) |
| 2989 |
} |
|
| 2990 |
} |
|
| 2991 | ||
| 2992 |
#' @export |
|
| 2993 |
#' @rdname scale_crameri_vikO |
|
| 2994 |
scale_color_vikO <- scale_colour_vikO |
|
| 2995 | ||
| 2996 |
#' @export |
|
| 2997 |
#' @rdname scale_crameri_vikO |
|
| 2998 |
scale_fill_vikO <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 2999 |
discrete = FALSE, aesthetics = "fill") {
|
|
| 3000 | 3x |
if (discrete) {
|
| 3001 | 1x |
scale_discrete(aesthetics, "vikO", reverse = reverse, ...) |
| 3002 |
} else {
|
|
| 3003 | 2x |
scale_continuous(aesthetics, "vikO", reverse = reverse, range = range, ...) |
| 3004 |
} |
|
| 3005 |
} |
|
| 3006 | ||
| 3007 |
## romaO ----------------------------------------------------------------------- |
|
| 3008 |
#' Fabio Crameri's *romaO* Cyclic Color Scheme |
|
| 3009 |
#' |
|
| 3010 |
#' @inheritParams scale_crameri_brocO |
|
| 3011 |
#' @inheritSection crameri Diverging Color Schemes |
|
| 3012 |
#' @return A [continuous][ggplot2::continuous_scale] scale. |
|
| 3013 |
#' @references |
|
| 3014 |
#' Crameri, F. (2018). Geodynamic diagnostics, scientific visualisation and |
|
| 3015 |
#' StagLab 3.0. *Geosci. Model Dev.*, 11, 2541-2562. |
|
| 3016 |
#' \doi{10.5194/gmd-11-2541-2018}
|
|
| 3017 |
#' |
|
| 3018 |
#' Crameri, F., Shephard, G. E. & Heron, P. J. (2020). The misuse of colour in |
|
| 3019 |
#' science communication. *Nature Communications*, 11, 5444. |
|
| 3020 |
#' \doi{10.1038/s41467-020-19160-7}
|
|
| 3021 |
#' @source |
|
| 3022 |
#' Crameri, F. (2023). Scientific colour maps. *Zenodo*, v8.0.1. |
|
| 3023 |
#' \doi{10.5281/zenodo.1243862}
|
|
| 3024 |
#' @example inst/examples/ex-crameri-diverging.R |
|
| 3025 |
#' @author N. Frerebeau |
|
| 3026 |
#' @family cyclic color schemes |
|
| 3027 |
#' @family Fabio Crameri's color schemes |
|
| 3028 |
#' @name scale_crameri_romaO |
|
| 3029 |
#' @rdname scale_crameri_romaO |
|
| 3030 |
NULL |
|
| 3031 | ||
| 3032 |
#' @export |
|
| 3033 |
#' @rdname scale_crameri_romaO |
|
| 3034 |
scale_colour_romaO <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 3035 |
discrete = FALSE, aesthetics = "colour") {
|
|
| 3036 | 5x |
if (discrete) {
|
| 3037 | 1x |
scale_discrete(aesthetics, "romaO", reverse = reverse, ...) |
| 3038 |
} else {
|
|
| 3039 | 4x |
scale_continuous(aesthetics, "romaO", reverse = reverse, range = range, ...) |
| 3040 |
} |
|
| 3041 |
} |
|
| 3042 | ||
| 3043 |
#' @export |
|
| 3044 |
#' @rdname scale_crameri_romaO |
|
| 3045 |
scale_color_romaO <- scale_colour_romaO |
|
| 3046 | ||
| 3047 |
#' @export |
|
| 3048 |
#' @rdname scale_crameri_romaO |
|
| 3049 |
scale_fill_romaO <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 3050 |
discrete = FALSE, aesthetics = "fill") {
|
|
| 3051 | 3x |
if (discrete) {
|
| 3052 | 1x |
scale_discrete(aesthetics, "romaO", reverse = reverse, ...) |
| 3053 |
} else {
|
|
| 3054 | 2x |
scale_continuous(aesthetics, "romaO", reverse = reverse, range = range, ...) |
| 3055 |
} |
|
| 3056 |
} |
|
| 3057 | ||
| 3058 |
## bamO ------------------------------------------------------------------------ |
|
| 3059 |
#' Fabio Crameri's *bamO* Cyclic Color Scheme |
|
| 3060 |
#' |
|
| 3061 |
#' @inheritParams scale_crameri_brocO |
|
| 3062 |
#' @inheritSection crameri Diverging Color Schemes |
|
| 3063 |
#' @return A [continuous][ggplot2::continuous_scale] scale. |
|
| 3064 |
#' @references |
|
| 3065 |
#' Crameri, F. (2018). Geodynamic diagnostics, scientific visualisation and |
|
| 3066 |
#' StagLab 3.0. *Geosci. Model Dev.*, 11, 2541-2562. |
|
| 3067 |
#' \doi{10.5194/gmd-11-2541-2018}
|
|
| 3068 |
#' |
|
| 3069 |
#' Crameri, F., Shephard, G. E. & Heron, P. J. (2020). The misuse of colour in |
|
| 3070 |
#' science communication. *Nature Communications*, 11, 5444. |
|
| 3071 |
#' \doi{10.1038/s41467-020-19160-7}
|
|
| 3072 |
#' @source |
|
| 3073 |
#' Crameri, F. (2023). Scientific colour maps. *Zenodo*, v8.0.1. |
|
| 3074 |
#' \doi{10.5281/zenodo.1243862}
|
|
| 3075 |
#' @example inst/examples/ex-crameri-diverging.R |
|
| 3076 |
#' @author N. Frerebeau |
|
| 3077 |
#' @family cyclic color schemes |
|
| 3078 |
#' @family Fabio Crameri's color schemes |
|
| 3079 |
#' @name scale_crameri_bamO |
|
| 3080 |
#' @rdname scale_crameri_bamO |
|
| 3081 |
NULL |
|
| 3082 | ||
| 3083 |
#' @export |
|
| 3084 |
#' @rdname scale_crameri_bamO |
|
| 3085 |
scale_colour_bamO <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 3086 |
discrete = FALSE, aesthetics = "colour") {
|
|
| 3087 | 5x |
if (discrete) {
|
| 3088 | 1x |
scale_discrete(aesthetics, "bamO", reverse = reverse, ...) |
| 3089 |
} else {
|
|
| 3090 | 4x |
scale_continuous(aesthetics, "bamO", reverse = reverse, range = range, ...) |
| 3091 |
} |
|
| 3092 |
} |
|
| 3093 | ||
| 3094 |
#' @export |
|
| 3095 |
#' @rdname scale_crameri_bamO |
|
| 3096 |
scale_color_bamO <- scale_colour_bamO |
|
| 3097 | ||
| 3098 |
#' @export |
|
| 3099 |
#' @rdname scale_crameri_bamO |
|
| 3100 |
scale_fill_bamO <- function(..., reverse = FALSE, range = c(0, 1), |
|
| 3101 |
discrete = FALSE, aesthetics = "fill") {
|
|
| 3102 | 3x |
if (discrete) {
|
| 3103 | 1x |
scale_discrete(aesthetics, "bamO", reverse = reverse, ...) |
| 3104 |
} else {
|
|
| 3105 | 2x |
scale_continuous(aesthetics, "bamO", reverse = reverse, range = range, ...) |
| 3106 |
} |
|
| 3107 |
} |
| 1 |
#' Plot Color Scheme |
|
| 2 |
#' |
|
| 3 |
#' Quickly displays a color scheme returned by [color()]. |
|
| 4 |
#' @param x A [`character`] vector of colors. |
|
| 5 |
#' @param ... Currently not used. |
|
| 6 |
#' @return |
|
| 7 |
#' `plot()` is called for its side-effects: it results in a graphic |
|
| 8 |
#' being displayed (invisibly returns `x`). |
|
| 9 |
#' @example inst/examples/ex-plot.R |
|
| 10 |
#' @author N. Frerebeau |
|
| 11 |
#' @family diagnostic tools |
|
| 12 |
#' @export |
|
| 13 |
plot.color_scheme <- function(x, ...) {
|
|
| 14 |
# Save and restore graphical parameters |
|
| 15 | ! |
old_par <- graphics::par(no.readonly = TRUE) |
| 16 | ! |
on.exit(graphics::par(old_par)) |
| 17 | ||
| 18 | ! |
n <- length(x) |
| 19 | ! |
graphics::par(mar = c(0, 0, 0, 0) + 0.1, xaxs = "i", yaxs = "i") |
| 20 | ! |
graphics::plot( |
| 21 | ! |
x = NULL, y = NULL, |
| 22 | ! |
xlim = c(0, n), ylim = c(0, 1), |
| 23 | ! |
xlab = "", ylab = "", axes = FALSE |
| 24 |
) |
|
| 25 | ! |
graphics::rect(xleft = seq(0, n - 1), xright = seq(1, n), |
| 26 | ! |
ybottom = 0.25, ytop = 0.75, col = x, border = NA) |
| 27 | ! |
if (n < 25) graphics::abline(v = seq(1, n), col = "#D3D3D3", lwd = 0.25) |
| 28 | ||
| 29 | ! |
invisible(x) |
| 30 |
} |
| 1 |
#' @include color.R |
|
| 2 |
NULL |
|
| 3 | ||
| 4 |
# Geologic Timescale =========================================================== |
|
| 5 |
#' Geologic Timescale Color Scheme for \pkg{ggplot2} and \pkg{ggraph}
|
|
| 6 |
#' |
|
| 7 |
#' Provides the geologic timescale color scheme. |
|
| 8 |
#' @param ... Arguments passed on to [ggplot2::discrete_scale()]. |
|
| 9 |
#' @param lang A [`character`] string specifying the language for the |
|
| 10 |
#' color names (see details). It must be one of "`en`" (english, the |
|
| 11 |
#' default), "`fr`" (french) or `NULL`. If not `NULL`, the values will be |
|
| 12 |
#' matched based on the color names. |
|
| 13 |
#' @param aesthetics A [`character`] string or vector of character |
|
| 14 |
#' strings listing the name(s) of the aesthetic(s) that this scale works with. |
|
| 15 |
#' @details Values will be matched based on the geological unit names. |
|
| 16 |
#' @return A [discrete][ggplot2::discrete_scale] scale. |
|
| 17 |
#' @references |
|
| 18 |
#' \href{https://www.ccgm.org/}{Commission for the Geological Map of the World}.
|
|
| 19 |
#' @example inst/examples/ex-science-stratigraphy.R |
|
| 20 |
#' @author N. Frerebeau |
|
| 21 |
#' @family themed color schemes |
|
| 22 |
#' @family qualitative color schemes |
|
| 23 |
#' @export |
|
| 24 |
#' @rdname scale_stratigraphy |
|
| 25 |
scale_colour_stratigraphy <- function(..., lang = "en", aesthetics = "colour") {
|
|
| 26 |
# Get palette |
|
| 27 | 5x |
color_palette <- color("stratigraphy", names = !is.null(lang), lang = lang)
|
| 28 |
# Build scale |
|
| 29 | 5x |
ggplot2::scale_color_manual(..., values = color_palette(175), |
| 30 | 5x |
aesthetics = aesthetics) |
| 31 |
} |
|
| 32 | ||
| 33 |
#' @export |
|
| 34 |
#' @rdname scale_stratigraphy |
|
| 35 |
scale_color_stratigraphy <- scale_colour_stratigraphy |
|
| 36 | ||
| 37 |
#' @export |
|
| 38 |
#' @rdname scale_stratigraphy |
|
| 39 |
scale_fill_stratigraphy <- function(..., lang = "en", aesthetics = "fill") {
|
|
| 40 |
# Get palette |
|
| 41 | 3x |
color_palette <- color("stratigraphy", names = !is.null(lang), lang = lang)
|
| 42 |
# Build scale |
|
| 43 | 3x |
ggplot2::scale_fill_manual(..., values = color_palette(175), |
| 44 | 3x |
aesthetics = aesthetics) |
| 45 |
} |
|
| 46 | ||
| 47 |
#' @export |
|
| 48 |
#' @rdname scale_stratigraphy |
|
| 49 |
scale_edge_colour_stratigraphy <- function(..., lang = "en") {
|
|
| 50 |
# Get palette |
|
| 51 | 5x |
color_palette <- color("stratigraphy", names = !is.null(lang), lang = lang)
|
| 52 |
# Build scale |
|
| 53 | 5x |
ggraph::scale_edge_colour_manual(..., values = color_palette(175)) |
| 54 |
} |
|
| 55 | ||
| 56 |
#' @export |
|
| 57 |
#' @rdname scale_stratigraphy |
|
| 58 |
scale_edge_color_stratigraphy <- scale_edge_colour_stratigraphy |
|
| 59 | ||
| 60 |
#' @export |
|
| 61 |
#' @rdname scale_stratigraphy |
|
| 62 |
scale_edge_fill_stratigraphy <- function(..., lang = "en") {
|
|
| 63 |
# Get palette |
|
| 64 | 3x |
color_palette <- color("stratigraphy", names = !is.null(lang), lang = lang)
|
| 65 |
# Build scale |
|
| 66 | 3x |
ggraph::scale_edge_fill_manual(..., values = color_palette(175)) |
| 67 |
} |
|
| 68 | ||
| 69 |
# Land ========================================================================= |
|
| 70 |
#' AVHRR Global Land Cover Classification Color Scheme for \pkg{ggplot2}
|
|
| 71 |
#' and \pkg{ggraph}
|
|
| 72 |
#' |
|
| 73 |
#' Provides the AVHRR Global Land Cover classification as modified by |
|
| 74 |
#' Paul Tol (colorblind safe). |
|
| 75 |
#' @param ... Arguments passed on to [ggplot2::discrete_scale()]. |
|
| 76 |
#' @param lang A [`character`] string specifying the language for the |
|
| 77 |
#' color names (see details). It must be one of "`en`" (english, the |
|
| 78 |
#' default), "`fr`" (french) or `NULL`. If not `NULL`, the values will be |
|
| 79 |
#' matched based on the color names. |
|
| 80 |
#' @param aesthetics A [`character`] string or vector of character |
|
| 81 |
#' strings listing the name(s) of the aesthetic(s) that this scale works with. |
|
| 82 |
#' @details Values will be matched based on the land classification names. |
|
| 83 |
#' @return A [discrete][ggplot2::discrete_scale] scale. |
|
| 84 |
#' @references |
|
| 85 |
#' Tol, P. (2018). *Colour Schemes.* SRON. Technical Note No. |
|
| 86 |
#' SRON/EPS/TN/09-002, issue 3.1. |
|
| 87 |
#' URL: \url{https://sronpersonalpages.nl/~pault/data/colourschemes.pdf}
|
|
| 88 |
#' @example inst/examples/ex-science-land.R |
|
| 89 |
#' @author N. Frerebeau |
|
| 90 |
#' @family themed color schemes |
|
| 91 |
#' @family qualitative color schemes |
|
| 92 |
#' @export |
|
| 93 |
#' @rdname scale_land |
|
| 94 |
scale_colour_land <- function(..., lang = "en", aesthetics = "colour") {
|
|
| 95 |
# Get palette |
|
| 96 | 5x |
color_palette <- color("land", names = !is.null(lang), lang = lang)
|
| 97 |
# Build scale |
|
| 98 | 5x |
ggplot2::scale_color_manual(..., values = color_palette(14), |
| 99 | 5x |
aesthetics = aesthetics) |
| 100 |
} |
|
| 101 | ||
| 102 |
#' @export |
|
| 103 |
#' @rdname scale_land |
|
| 104 |
scale_color_land <- scale_colour_land |
|
| 105 | ||
| 106 |
#' @export |
|
| 107 |
#' @rdname scale_land |
|
| 108 |
scale_fill_land <- function(..., lang = "en", aesthetics = "fill") {
|
|
| 109 |
# Get palette |
|
| 110 | 3x |
color_palette <- color("land", names = !is.null(lang), lang = lang)
|
| 111 |
# Build scale |
|
| 112 | 3x |
ggplot2::scale_fill_manual(..., values = color_palette(14), |
| 113 | 3x |
aesthetics = aesthetics) |
| 114 |
} |
|
| 115 | ||
| 116 |
#' @export |
|
| 117 |
#' @rdname scale_land |
|
| 118 |
scale_edge_colour_land <- function(..., lang = "en") {
|
|
| 119 |
# Get palette |
|
| 120 | 5x |
color_palette <- color("land", names = !is.null(lang), lang = lang)
|
| 121 |
# Build scale |
|
| 122 | 5x |
ggraph::scale_edge_colour_manual(..., values = color_palette(14)) |
| 123 |
} |
|
| 124 | ||
| 125 |
#' @export |
|
| 126 |
#' @rdname scale_land |
|
| 127 |
scale_edge_color_land <- scale_edge_colour_land |
|
| 128 | ||
| 129 |
#' @export |
|
| 130 |
#' @rdname scale_land |
|
| 131 |
scale_edge_fill_land <- function(..., lang = "en") {
|
|
| 132 |
# Get palette |
|
| 133 | 3x |
color_palette <- color("land", names = !is.null(lang), lang = lang)
|
| 134 |
# Build scale |
|
| 135 | 3x |
ggraph::scale_edge_fill_manual(..., values = color_palette(14)) |
| 136 |
} |
|
| 137 | ||
| 138 |
# Soil ========================================================================= |
|
| 139 |
#' FAO Soil Reference Groups Color Scheme for \pkg{ggplot2} and \pkg{ggraph}
|
|
| 140 |
#' |
|
| 141 |
#' Provides the FAO Soil Reference Groups color scheme. |
|
| 142 |
#' @param ... Arguments passed on to [ggplot2::discrete_scale()]. |
|
| 143 |
#' @param lang A [`character`] string specifying the language for the |
|
| 144 |
#' color names (see details). It must be one of "`en`" (english, the |
|
| 145 |
#' default), "`fr`" (french) or `NULL`. If not `NULL`, the values will be |
|
| 146 |
#' matched based on the color names. |
|
| 147 |
#' @param aesthetics A [`character`] string or vector of character |
|
| 148 |
#' strings listing the name(s) of the aesthetic(s) that this scale works with. |
|
| 149 |
#' @details Values will be matched based on the soil names. |
|
| 150 |
#' @references |
|
| 151 |
#' Jones, A., Montanarella, L. & Jones, R. (Ed.) (2005). *Soil atlas of |
|
| 152 |
#' Europe*. Luxembourg: European Commission, Office for Official Publications |
|
| 153 |
#' of the European Communities. 128 pp. ISBN: 92-894-8120-X. |
|
| 154 |
#' @return A [discrete][ggplot2::discrete_scale] scale. |
|
| 155 |
#' @example inst/examples/ex-science-soil.R |
|
| 156 |
#' @author N. Frerebeau |
|
| 157 |
#' @family themed color schemes |
|
| 158 |
#' @family qualitative color schemes |
|
| 159 |
#' @export |
|
| 160 |
#' @rdname scale_soil |
|
| 161 |
scale_colour_soil <- function(..., lang = "en", aesthetics = "colour") {
|
|
| 162 |
# Get palette |
|
| 163 | 5x |
color_palette <- color("soil", names = !is.null(lang), lang = lang)
|
| 164 |
# Build scale |
|
| 165 | 5x |
ggplot2::scale_color_manual(..., values = color_palette(24), |
| 166 | 5x |
aesthetics = aesthetics) |
| 167 |
} |
|
| 168 | ||
| 169 |
#' @export |
|
| 170 |
#' @rdname scale_soil |
|
| 171 |
scale_color_soil <- scale_colour_soil |
|
| 172 | ||
| 173 |
#' @export |
|
| 174 |
#' @rdname scale_soil |
|
| 175 |
scale_fill_soil <- function(..., lang = "en", aesthetics = "fill") {
|
|
| 176 |
# Get palette |
|
| 177 | 3x |
color_palette <- color("soil", names = !is.null(lang), lang = lang)
|
| 178 |
# Build scale |
|
| 179 | 3x |
ggplot2::scale_fill_manual(..., values = color_palette(24), |
| 180 | 3x |
aesthetics = aesthetics) |
| 181 |
} |
|
| 182 | ||
| 183 |
#' @export |
|
| 184 |
#' @rdname scale_soil |
|
| 185 |
scale_edge_colour_soil <- function(..., lang = "en") {
|
|
| 186 |
# Get palette |
|
| 187 | 5x |
color_palette <- color("soil", names = !is.null(lang), lang = lang)
|
| 188 |
# Build scale |
|
| 189 | 5x |
ggraph::scale_edge_colour_manual(..., values = color_palette(24)) |
| 190 |
} |
|
| 191 | ||
| 192 |
#' @export |
|
| 193 |
#' @rdname scale_soil |
|
| 194 |
scale_edge_color_soil <- scale_edge_colour_soil |
|
| 195 | ||
| 196 |
#' @export |
|
| 197 |
#' @rdname scale_soil |
|
| 198 |
scale_edge_fill_soil <- function(..., lang = "en") {
|
|
| 199 |
# Get palette |
|
| 200 | 3x |
color_palette <- color("soil", names = !is.null(lang), lang = lang)
|
| 201 |
# Build scale |
|
| 202 | 3x |
ggraph::scale_edge_fill_manual(..., values = color_palette(24)) |
| 203 |
} |
| 1 |
#' Diagnostic Map |
|
| 2 |
#' |
|
| 3 |
#' Produces a diagnostic map for a given color scheme. |
|
| 4 |
#' @param x A [`character`] vector of colors. |
|
| 5 |
#' @return |
|
| 6 |
#' `plot_map()` is called for its side-effects: it results in a graphic |
|
| 7 |
#' being displayed (invisibly returns `x`). |
|
| 8 |
#' @example inst/examples/ex-plot.R |
|
| 9 |
#' @author N. Frerebeau, V. Arel-Bundock |
|
| 10 |
#' @family diagnostic tools |
|
| 11 |
#' @export |
|
| 12 |
plot_map <- function(x) {
|
|
| 13 |
# Validation |
|
| 14 | 1x |
assert_color(x) |
| 15 | ||
| 16 |
# Save and restore graphical parameters |
|
| 17 | ! |
old_par <- graphics::par(no.readonly = TRUE) |
| 18 | ! |
on.exit(graphics::par(old_par)) |
| 19 | ||
| 20 | ! |
n <- length(x) # Number of colors |
| 21 | ! |
q <- floor(100 / (n + 1)) |
| 22 | ||
| 23 | ! |
graphics::par(mar = c(0, 0, 0, 0) + 0.1, xaxs = "i", yaxs = "i") |
| 24 | ! |
graphics::plot( |
| 25 | ! |
x = NULL, y = NULL, |
| 26 | ! |
xlim = c(0, (q * (n + 1) / 2) + 1), ylim = c(0, 10.5), |
| 27 | ! |
xlab = "", ylab = "", axes = FALSE, asp = 1 |
| 28 |
) |
|
| 29 | ||
| 30 | ! |
random_colors <- sample(x, size = 19 * q, replace = TRUE) |
| 31 | ! |
draw_mosaic(columns = q, border = "black", fill = random_colors) |
| 32 | ||
| 33 | ! |
for (h in seq_len(n)) {
|
| 34 | ! |
random_positions <- sample(seq_len(19 * q), size = n, replace = FALSE) |
| 35 | ! |
unique_color <- rep(x[[h]], length.out = 19 * q) |
| 36 | ! |
unique_color[random_positions] <- x |
| 37 | ||
| 38 | ! |
draw_mosaic(columns = q, border = "black", fill = unique_color, offset = h) |
| 39 |
} |
|
| 40 | ||
| 41 | ! |
invisible(x) |
| 42 |
} |
|
| 43 | ||
| 44 |
#' Mosaic |
|
| 45 |
#' |
|
| 46 |
#' Draws a mosaic of diamonds. |
|
| 47 |
#' @param rows An [`integer`] giving the number of lines. |
|
| 48 |
#' @param columns An [`integer`] giving the number of columns. |
|
| 49 |
#' @param border A [`character`] string giving the color to draw the |
|
| 50 |
#' border (see \code{\link[graphics]{polygon}}).
|
|
| 51 |
#' @param fill A [`character`] string giving the color for filling |
|
| 52 |
#' the polygon (see \code{\link[graphics]{polygon}}).
|
|
| 53 |
#' @param offset An [`numeric`] value giving the \code{x} offset from
|
|
| 54 |
#' zero of the mosaic. |
|
| 55 |
#' @keywords internal |
|
| 56 |
#' @noRd |
|
| 57 |
draw_mosaic <- function(rows = 19, columns = 10, border = NULL, fill = NA, |
|
| 58 |
offset = 0) {
|
|
| 59 | ! |
fill <- rep(fill, length.out = rows * columns) |
| 60 | ! |
k <- 1 |
| 61 | ! |
for (i in seq_len(rows)) { # Loop over lines
|
| 62 | ! |
even <- i %% 2 == 0 |
| 63 | ! |
for (j in seq_len(columns)) { # Loop over columns
|
| 64 | ! |
graphics::polygon( |
| 65 | ! |
x = c(0, 0.25, 0.5, 0.25) + |
| 66 | ! |
j * 0.5 + 0.25 * even + |
| 67 | ! |
columns * offset / 2, |
| 68 | ! |
y = c(0.5, 1, 0.5, 0) + i * 0.5, |
| 69 | ! |
border = border, |
| 70 | ! |
col = fill[[k]] |
| 71 |
) |
|
| 72 | ! |
k <- k + 1 |
| 73 |
} |
|
| 74 |
} |
|
| 75 |
} |
|
| 76 | ||
| 77 |
# draw_diamond <- function(x = 0, y = 0, width = 0.5, height = 1, |
|
| 78 |
# border = NULL, fill = NA) {
|
|
| 79 |
# half_width <- width / 2 |
|
| 80 |
# half_height <- height / 2 |
|
| 81 |
# graphics::polygon( |
|
| 82 |
# x = c(x - half_width, x, x + half_width, x), |
|
| 83 |
# y = c(y, y + half_height, y, y - half_height), |
|
| 84 |
# border = border, |
|
| 85 |
# col = fill |
|
| 86 |
# ) |
|
| 87 |
# } |
| 1 |
#' Color Schemes |
|
| 2 |
#' |
|
| 3 |
#' Provides qualitative, diverging and sequential color schemes. |
|
| 4 |
#' @param palette A [`character`] string giving the name of the scheme to be |
|
| 5 |
#' used (see [info()]). |
|
| 6 |
#' @param reverse A [`logical`] scalar: should the resulting vector of colors |
|
| 7 |
#' should be reversed? |
|
| 8 |
#' @param names A [`logical`] scalar: should the names of the colors should be |
|
| 9 |
#' kept in the resulting vector? |
|
| 10 |
#' @param lang A [`character`] string specifying the language for the color |
|
| 11 |
#' names. It must be one of "`en`" (English, the default) or "`fr`" (French). |
|
| 12 |
#' @param force A [`logical`] scalar. If `TRUE`, forces the color scheme to be |
|
| 13 |
#' interpolated. It should not be used routinely with qualitative color |
|
| 14 |
#' schemes, as they are designed to be used as is to remain color-blind safe. |
|
| 15 |
#' @param ... Further arguments passed to |
|
| 16 |
#' [colorRampPalette][grDevices::colorRamp]. |
|
| 17 |
#' @return |
|
| 18 |
#' A [`function`] function with the following attributes, that when called |
|
| 19 |
#' with a single argument (an [`integer`] specifying the number of colors) |
|
| 20 |
#' returns a (named) vector of colors. |
|
| 21 |
#' |
|
| 22 |
#' \describe{
|
|
| 23 |
#' \item{palette}{A [`character`] string giving the name of the
|
|
| 24 |
#' color scheme.} |
|
| 25 |
#' \item{type}{A [`character`] string giving the corresponding
|
|
| 26 |
#' data type. One of "`qualitative`", "`diverging`" or "`sequential`".} |
|
| 27 |
#' \item{interpolate}{A [`logical`] scalar: can the color palette be
|
|
| 28 |
#' interpolated?} |
|
| 29 |
#' \item{missing}{A [`character`] string giving the the hexadecimal
|
|
| 30 |
#' representation of the color that should be used for `NA` values.} |
|
| 31 |
#' \item{max}{An [`integer`] giving the maximum number of color values.
|
|
| 32 |
#' Only relevant for non-interpolated color schemes.} |
|
| 33 |
#' } |
|
| 34 |
#' |
|
| 35 |
#' For color schemes that can be interpolated (diverging and sequential data), |
|
| 36 |
#' the color range can be limited with an additional argument. `range` allows |
|
| 37 |
#' to remove a fraction of the color domain (before being interpolated; see |
|
| 38 |
#' examples). |
|
| 39 |
#' @references |
|
| 40 |
#' Crameri, F. (2018). Geodynamic diagnostics, scientific visualisation and |
|
| 41 |
#' StagLab 3.0. *Geosci. Model Dev.*, 11, 2541-2562. |
|
| 42 |
#' \doi{10.5194/gmd-11-2541-2018}
|
|
| 43 |
#' |
|
| 44 |
#' Crameri, F., Shephard, G. E. & Heron, P. J. (2020). The misuse of colour in |
|
| 45 |
#' science communication. *Nature Communications*, 11, 5444. |
|
| 46 |
#' \doi{10.1038/s41467-020-19160-7}
|
|
| 47 |
#' |
|
| 48 |
#' Jones, A., Montanarella, L. & Jones, R. (Ed.) (2005). *Soil atlas of |
|
| 49 |
#' Europe*. Luxembourg: European Commission, Office for Official Publications |
|
| 50 |
#' of the European Communities. 128 pp. ISBN: 92-894-8120-X. |
|
| 51 |
#' |
|
| 52 |
#' Okabe, M. & Ito, K. (2008). *Color Universal Design (CUD): How to Make |
|
| 53 |
#' Figures and Presentations That Are Friendly to Colorblind People*. |
|
| 54 |
#' URL: \url{https://jfly.uni-koeln.de/color/}.
|
|
| 55 |
#' |
|
| 56 |
#' Tol, P. (2021). *Colour Schemes*. SRON. Technical Note No. |
|
| 57 |
#' SRON/EPS/TN/09-002, issue 3.2. |
|
| 58 |
#' URL: \url{https://sronpersonalpages.nl/~pault/data/colourschemes.pdf}
|
|
| 59 |
#' |
|
| 60 |
#' \href{https://www.ccgm.org/}{Commission for the Geological Map of the World}.
|
|
| 61 |
#' @example inst/examples/ex-palettes.R |
|
| 62 |
#' @author N. Frerebeau |
|
| 63 |
#' @family color schemes |
|
| 64 |
#' @keywords color |
|
| 65 |
#' @export |
|
| 66 |
colour <- function(palette, reverse = FALSE, names = FALSE, lang = "en", |
|
| 67 |
force = FALSE, ...) {
|
|
| 68 |
## Validation |
|
| 69 | 1858x |
palette <- gsub(pattern = "[[:blank:]]", replacement = "", x = palette) |
| 70 | 1858x |
palette <- match.arg(palette, names(.schemes), several.ok = FALSE) |
| 71 | 1858x |
lang <- match.arg(lang, c("en", "fr"), several.ok = FALSE)
|
| 72 | ||
| 73 |
## Get colors |
|
| 74 | 1858x |
col_palette <- .schemes[[palette]] |
| 75 | 1858x |
col_colors <- col_palette[["colours"]] |
| 76 | 1858x |
col_names <- col_palette[["names"]][[lang]] |
| 77 | 1858x |
col_type <- col_palette[["type"]] |
| 78 | 1858x |
col_interpolate <- col_palette[["interpolate"]] |
| 79 | 1858x |
col_missing <- col_palette[["missing"]] |
| 80 | 1858x |
col_scheme <- col_palette[["scheme"]] |
| 81 | 1858x |
k <- col_palette[["max"]] |
| 82 | ||
| 83 |
## Reverse color order |
|
| 84 | 54x |
if (reverse) col_colors <- rev(col_colors) |
| 85 | ||
| 86 | 1858x |
if (col_interpolate || force) {
|
| 87 | ||
| 88 |
## For color schemes that can be linearly interpolated |
|
| 89 | 1347x |
fun <- function(n, range = c(0, 1)) {
|
| 90 | 51x |
if (missing(n)) n <- k |
| 91 |
# Validate |
|
| 92 | 953x |
if (any(range > 1) || any(range < 0)) {
|
| 93 | ! |
msg <- tr_("%s values must be in [0,1].")
|
| 94 | ! |
stop(sprintf(msg, sQuote("range")), call. = FALSE)
|
| 95 |
} |
|
| 96 |
# Remove starting colors |
|
| 97 | 953x |
col_colors <- utils::tail(col_colors, k * (1 - range[[1]])) |
| 98 |
# Remove ending colors |
|
| 99 | 953x |
col_colors <- utils::head(col_colors, k * range[[2]]) |
| 100 |
# Interpolate |
|
| 101 | 953x |
col <- grDevices::colorRampPalette(col_colors)(n) |
| 102 |
# Set attributes |
|
| 103 | 953x |
col <- structure( |
| 104 | 953x |
col, |
| 105 | 953x |
missing = col_missing, |
| 106 | 953x |
class = c("color_scheme", "color_continuous")
|
| 107 |
) |
|
| 108 | 953x |
return(col) |
| 109 |
} |
|
| 110 | ||
| 111 |
} else {
|
|
| 112 | ||
| 113 |
## No interpolation |
|
| 114 |
## FIXME: add 'range = c(0, 1)' to prevent "multiple local function |
|
| 115 |
## definitions" note in R CMD check |
|
| 116 | 511x |
fun <- function(n, range = c(0, 1)) {
|
| 117 | 17x |
if (missing(n)) n <- k |
| 118 |
# Validate |
|
| 119 | 288x |
if (n > k) {
|
| 120 | 15x |
msg <- tr_("%s color scheme supports up to %d values.")
|
| 121 | 15x |
stop(sprintf(msg, sQuote(palette), k), call. = FALSE) |
| 122 |
} |
|
| 123 |
# Arrange color schemes |
|
| 124 | 273x |
if (!is.null(col_scheme)) {
|
| 125 | 12x |
m <- col_scheme[[n]] |
| 126 | 12x |
if (reverse) {
|
| 127 | 1x |
m <- rev(m) |
| 128 | 1x |
col_colors <- rev(col_colors) |
| 129 |
} |
|
| 130 | 12x |
col <- col_colors[m] |
| 131 | 261x |
} else if (col_type == "qualitative") {
|
| 132 | 261x |
m <- seq_len(n) |
| 133 | 261x |
col <- col_colors[m] |
| 134 |
} else {
|
|
| 135 | ! |
m <- seq(from = 1, to = k, length.out = n) |
| 136 | ! |
col <- col_colors[m] |
| 137 |
} |
|
| 138 |
# Keep names? |
|
| 139 | 193x |
if (names) names(col) <- col_names[m] else col <- unname(col) |
| 140 |
# Set attributes |
|
| 141 | 273x |
col <- structure( |
| 142 | 273x |
col, |
| 143 | 273x |
missing = col_missing, |
| 144 | 273x |
class = c("color_scheme", "color_discrete")
|
| 145 |
) |
|
| 146 | 273x |
return(col) |
| 147 |
} |
|
| 148 | ||
| 149 |
} |
|
| 150 |
## Set attributes |
|
| 151 | 1858x |
fun <- structure( |
| 152 | 1858x |
fun, |
| 153 | 1858x |
palette = palette, |
| 154 | 1858x |
type = col_type, |
| 155 | 1858x |
missing = col_missing, |
| 156 | 1858x |
interpolate = col_interpolate || force, |
| 157 | 1858x |
max = as.integer(k) |
| 158 |
) |
|
| 159 | 1858x |
return(fun) |
| 160 |
} |
|
| 161 | ||
| 162 |
#' @export |
|
| 163 |
#' @rdname colour |
|
| 164 |
color <- colour |
| 1 |
#' Color Difference |
|
| 2 |
#' |
|
| 3 |
#' Computes CIELAB distance metric. |
|
| 4 |
#' @param x A [`character`] vector of colors. |
|
| 5 |
#' @param metric An [`integer`] value giving the year the metric was |
|
| 6 |
#' recommended by the CIE. It must be one of "`1976`", "`1994`", or |
|
| 7 |
#' "`2000`" (default; see [spacesXYZ::DeltaE()]). |
|
| 8 |
#' @param diag A [`logical`] scalar: should the diagonal of the distance matrix |
|
| 9 |
#' be printed? |
|
| 10 |
#' @param upper A [`logical`] scalar: should the upper triangle of the distance |
|
| 11 |
#' matrix should be printed? |
|
| 12 |
#' @return A [distance matrix][stats::dist]. |
|
| 13 |
#' @example inst/examples/ex-compare.R |
|
| 14 |
#' @author N. Frerebeau |
|
| 15 |
#' @family diagnostic tools |
|
| 16 |
#' @export |
|
| 17 |
compare <- function(x, metric = 2000, diag = FALSE, upper = FALSE) {
|
|
| 18 |
# Validation |
|
| 19 | 1x |
assert_package("spacesXYZ")
|
| 20 | 1x |
assert_color(x) |
| 21 | ||
| 22 |
# Hex to RGB |
|
| 23 | 1x |
RGB <- t(grDevices::col2rgb(x, alpha = FALSE)) |
| 24 |
# RGB to Lab |
|
| 25 | 1x |
Lab <- XYZ2Lab(RGB2XYZ(RGB)) |
| 26 | ||
| 27 |
# Color comparisons |
|
| 28 | 1x |
delta_E <- apply( |
| 29 | 1x |
X = Lab, |
| 30 | 1x |
MARGIN = 1, |
| 31 | 1x |
FUN = spacesXYZ::DeltaE, |
| 32 | 1x |
Lab2 = Lab, |
| 33 | 1x |
metric = metric[[1L]] |
| 34 |
) |
|
| 35 | ||
| 36 | 1x |
stats::as.dist(delta_E, diag = diag, upper = upper) |
| 37 |
} |
| 1 |
#' Available Schemes |
|
| 2 |
#' |
|
| 3 |
#' Returns information about the available schemes. |
|
| 4 |
#' @return |
|
| 5 |
#' A [`data.frame`] with the following columns: |
|
| 6 |
#' \describe{
|
|
| 7 |
#' \item{`palette`}{Names of palette.}
|
|
| 8 |
#' \item{`type`}{Types of schemes: sequential, diverging or qualitative.}
|
|
| 9 |
#' \item{`max`}{Maximum number of colors that are contained in each
|
|
| 10 |
#' palette. Only relevant for qualitative schemes.} |
|
| 11 |
#' \item{`missing`}{The hexadecimal color value for mapping missing values.}
|
|
| 12 |
#' } |
|
| 13 |
#' @example inst/examples/ex-info.R |
|
| 14 |
#' @author N. Frerebeau |
|
| 15 |
#' @family color schemes |
|
| 16 |
#' @export |
|
| 17 |
info <- function() {
|
|
| 18 | 2x |
meta <- lapply( |
| 19 | 2x |
X = .schemes, |
| 20 | 2x |
FUN = function(x) {
|
| 21 | 124x |
list(type = x$type, max = x$max, missing = x$missing) |
| 22 |
} |
|
| 23 |
) |
|
| 24 | 2x |
meta <- do.call(rbind.data.frame, meta) |
| 25 | 2x |
rownames(meta) <- NULL |
| 26 | 2x |
colnames(meta) <- c("type", "max", "missing")
|
| 27 | 2x |
meta$palette <- names(.schemes) |
| 28 | 2x |
meta[, c(4, 1, 2, 3)] |
| 29 |
} |
|
| 30 | ||
| 31 |
# Paul Tol ===================================================================== |
|
| 32 |
#' Paul Tol's Color Schemes |
|
| 33 |
#' |
|
| 34 |
#' @details |
|
| 35 |
#' The maximum number of supported colors is only relevant for the qualitative |
|
| 36 |
#' color schemes (divergent and sequential schemes are linearly interpolated). |
|
| 37 |
#' |
|
| 38 |
#' \describe{
|
|
| 39 |
#' \item{Qualitative data}{`bright` (7), `high contrast` (3), `vibrant` (7),
|
|
| 40 |
#' `muted` (9), `medium contrast` (6), `pale` (6), `dark` (6), `light` (9).} |
|
| 41 |
#' \item{Diverging data}{`sunset` (11), `nightfall` (17), `BuRd` (9),
|
|
| 42 |
#' `PRGn` (9).} |
|
| 43 |
#' \item{Sequential data}{`YlOrBr` (9), `iridescent` (23), `incandescent`
|
|
| 44 |
#' (11), `discrete rainbow` (23), `smooth rainbow` (34).} |
|
| 45 |
#' } |
|
| 46 |
#' @section Qualitative Color Schemes: |
|
| 47 |
#' The qualitative color schemes are used as given (no interpolation): |
|
| 48 |
#' colors are picked up to the maximum number of supported values. |
|
| 49 |
#' |
|
| 50 |
#' \tabular{ll}{
|
|
| 51 |
#' **Palette** \tab **Max.** \cr |
|
| 52 |
#' `bright` \tab 7 \cr |
|
| 53 |
#' `highcontrast` \tab 3 \cr |
|
| 54 |
#' `vibrant` \tab 7 \cr |
|
| 55 |
#' `muted` \tab 9 \cr |
|
| 56 |
#' `mediumcontrast` \tab 6 \cr |
|
| 57 |
#' `pale` \tab 6 \cr |
|
| 58 |
#' `dark` \tab 6 \cr |
|
| 59 |
#' `light` \tab 9 \cr |
|
| 60 |
#' } |
|
| 61 |
#' |
|
| 62 |
#' According to Paul Tol's technical note, the `bright`, `highcontrast`, |
|
| 63 |
#' `vibrant` and `muted` color schemes are color-blind safe. The |
|
| 64 |
#' `mediumcontrast` color scheme is designed for situations needing color |
|
| 65 |
#' pairs. |
|
| 66 |
#' |
|
| 67 |
#' The `light` color scheme is reasonably distinct for both normal or |
|
| 68 |
#' colorblind vision and is intended to fill labeled cells. |
|
| 69 |
#' |
|
| 70 |
#' The `pale` and `dark` schemes are not very distinct in either normal or |
|
| 71 |
#' colorblind vision and should be used as a text background or to highlight |
|
| 72 |
#' a cell in a table. |
|
| 73 |
#' |
|
| 74 |
#' Refer to the original document for details about the recommended uses (see |
|
| 75 |
#' references) |
|
| 76 |
#' @section Diverging Color Schemes: |
|
| 77 |
#' If more colors than defined are needed from a given scheme, the color |
|
| 78 |
#' coordinates are linearly interpolated to provide a continuous version of the |
|
| 79 |
#' scheme. |
|
| 80 |
#' |
|
| 81 |
#' \tabular{lll}{
|
|
| 82 |
#' **Palette** \tab **Max.** \tab **NA value** \cr |
|
| 83 |
#' `sunset` \tab 11 \tab #FFFFFF \cr |
|
| 84 |
#' `nightfall` \tab 17 \tab #FFFFFF \cr |
|
| 85 |
#' `BuRd` \tab 9 \tab #FFEE99 \cr |
|
| 86 |
#' `PRGn` \tab 9 \tab #FFEE99 \cr |
|
| 87 |
#' } |
|
| 88 |
#' |
|
| 89 |
#' @section Sequential Color Schemes: |
|
| 90 |
#' If more colors than defined are needed from a given scheme, the color |
|
| 91 |
#' coordinates are linearly interpolated to provide a continuous version of the |
|
| 92 |
#' scheme. |
|
| 93 |
#' |
|
| 94 |
#' \tabular{lll}{
|
|
| 95 |
#' **Palette** \tab **Max.** \tab **NA value** \cr |
|
| 96 |
#' `YlOrBr` \tab 9 \tab #888888 \cr |
|
| 97 |
#' `iridescent` \tab 23 \tab #999999 \cr |
|
| 98 |
#' `discreterainbow` \tab 23 \tab #777777 \cr |
|
| 99 |
#' `smoothrainbow` \tab 34 \tab #666666 \cr |
|
| 100 |
#' } |
|
| 101 |
#' @section Rainbow Color Scheme: |
|
| 102 |
#' As a general rule, ordered data should not be represented using a rainbow |
|
| 103 |
#' scheme. There are three main arguments against such use (Tol 2018): |
|
| 104 |
#' \itemize{
|
|
| 105 |
#' \item{The spectral order of visible light carries no inherent magnitude
|
|
| 106 |
#' message.} |
|
| 107 |
#' \item{Some bands of almost constant hue with sharp transitions between
|
|
| 108 |
#' them, can be perceived as jumps in the data.} |
|
| 109 |
#' \item{Color-blind people have difficulty distinguishing some colors of
|
|
| 110 |
#' the rainbow.} |
|
| 111 |
#' } |
|
| 112 |
#' If such use cannot be avoided, Paul Tol's technical note provides two color |
|
| 113 |
#' schemes that are reasonably clear in color-blind vision. To remain |
|
| 114 |
#' color-blind safe, these two schemes must comply with the following |
|
| 115 |
#' conditions: |
|
| 116 |
#' \describe{
|
|
| 117 |
#' \item{`discreterainbow`}{This scheme must not be interpolated.}
|
|
| 118 |
#' \item{`smoothrainbow`}{This scheme does not have to be used over the full
|
|
| 119 |
#' range.} |
|
| 120 |
#' } |
|
| 121 |
#' @references |
|
| 122 |
#' Tol, P. (2021). *Colour Schemes*. SRON. Technical Note No. |
|
| 123 |
#' SRON/EPS/TN/09-002, issue 3.2. |
|
| 124 |
#' URL: \url{https://sronpersonalpages.nl/~pault/data/colourschemes.pdf}
|
|
| 125 |
#' @keywords internal |
|
| 126 |
#' @rdname tol |
|
| 127 |
#' @name tol |
|
| 128 |
NULL |
|
| 129 | ||
| 130 |
# Fabio Crameri ================================================================ |
|
| 131 |
#' Fabio Crameri's Color Schemes |
|
| 132 |
#' |
|
| 133 |
#' @section Diverging Color Schemes: |
|
| 134 |
#' If more colors than defined are needed from a given scheme, the color |
|
| 135 |
#' coordinates are linearly interpolated to provide a continuous version of the |
|
| 136 |
#' scheme. |
|
| 137 |
#' |
|
| 138 |
#' \tabular{ll}{
|
|
| 139 |
#' **Palette** \tab **Max.** \cr |
|
| 140 |
#' `bam` \tab 256 \cr |
|
| 141 |
#' `bamO`* \tab 256 \cr |
|
| 142 |
#' `berlin` \tab 256 \cr |
|
| 143 |
#' `broc` \tab 256 \cr |
|
| 144 |
#' `brocO`* \tab 256 \cr |
|
| 145 |
#' `cork` \tab 256 \cr |
|
| 146 |
#' `corkO`* \tab 256 \cr |
|
| 147 |
#' `lisbon` \tab 256 \cr |
|
| 148 |
#' `managua` \tab 256 \cr |
|
| 149 |
#' `roma` \tab 256 \cr |
|
| 150 |
#' `romaO`* \tab 256 \cr |
|
| 151 |
#' `tofino` \tab 256 \cr |
|
| 152 |
#' `vanimo` \tab 256 \cr |
|
| 153 |
#' `vik` \tab 256 \cr |
|
| 154 |
#' `vikO`* \tab 256 \cr |
|
| 155 |
#' } |
|
| 156 |
#' *: cyclic color schemes. |
|
| 157 |
#' @section Sequential Color Schemes: |
|
| 158 |
#' If more colors than defined are needed from a given scheme, the color |
|
| 159 |
#' coordinates are linearly interpolated to provide a continuous version of the |
|
| 160 |
#' scheme. |
|
| 161 |
#' |
|
| 162 |
#' \tabular{ll}{
|
|
| 163 |
#' **Palette** \tab **Max.** \cr |
|
| 164 |
#' `acton` \tab 256 \cr |
|
| 165 |
#' `bamako` \tab 256 \cr |
|
| 166 |
#' `batlow` \tab 256 \cr |
|
| 167 |
#' `batlowW` \tab 256 \cr |
|
| 168 |
#' `batlowK` \tab 256 \cr |
|
| 169 |
#' `bilbao` \tab 256 \cr |
|
| 170 |
#' `buda` \tab 256 \cr |
|
| 171 |
#' `bukavu`* \tab 256 \cr |
|
| 172 |
#' `davos` \tab 256 \cr |
|
| 173 |
#' `devon` \tab 256 \cr |
|
| 174 |
#' `fes`* \tab 256 \cr |
|
| 175 |
#' `glasgow` \tab 256 \cr |
|
| 176 |
#' `grayC` \tab 256 \cr |
|
| 177 |
#' `hawaii` \tab 256 \cr |
|
| 178 |
#' `imola` \tab 256 \cr |
|
| 179 |
#' `lajolla` \tab 256 \cr |
|
| 180 |
#' `lapaz` \tab 256 \cr |
|
| 181 |
#' `navia` \tab 256 \cr |
|
| 182 |
#' `naviaW` \tab 256 \cr |
|
| 183 |
#' `nuuk` \tab 256 \cr |
|
| 184 |
#' `oleron`* \tab 256 \cr |
|
| 185 |
#' `oslo` \tab 256 \cr |
|
| 186 |
#' `tokyo` \tab 256 \cr |
|
| 187 |
#' `turku` \tab 256 \cr |
|
| 188 |
#' } |
|
| 189 |
#' *: multisequential color schemes. |
|
| 190 |
#' @references |
|
| 191 |
#' Crameri, F. (2018). Geodynamic diagnostics, scientific visualisation and |
|
| 192 |
#' StagLab 3.0. *Geosci. Model Dev.*, 11, 2541-2562. |
|
| 193 |
#' \doi{10.5194/gmd-11-2541-2018}
|
|
| 194 |
#' |
|
| 195 |
#' Crameri, F., Shephard, G. E. & Heron, P. J. (2020). The misuse of colour in |
|
| 196 |
#' science communication. *Nature Communications*, 11, 5444. |
|
| 197 |
#' \doi{10.1038/s41467-020-19160-7}
|
|
| 198 |
#' @source |
|
| 199 |
#' Crameri, F. (2023). Scientific colour maps. *Zenodo*, v8.0.1. |
|
| 200 |
#' \doi{10.5281/zenodo.1243862}
|
|
| 201 |
#' @keywords internal |
|
| 202 |
#' @rdname crameri |
|
| 203 |
#' @name crameri |
|
| 204 |
NULL |
|
| 205 | ||
| 206 |
# Science ====================================================================== |
|
| 207 |
#' Scientific Color Schemes |
|
| 208 |
#' |
|
| 209 |
#' @details |
|
| 210 |
#' The following (qualitative) color schemes are available: |
|
| 211 |
#' \describe{
|
|
| 212 |
#' \item{`stratigraphy`}{International Chronostratigraphic Chart (175 colors).}
|
|
| 213 |
#' \item{`land`}{AVHRR Global Land Cover Classification (14 colors).}
|
|
| 214 |
#' \item{`soil`}{FAO Reference Soil Groups (24 colors).}
|
|
| 215 |
#' } |
|
| 216 |
#' @references |
|
| 217 |
#' Jones, A., Montanarella, L. & Jones, R. (Ed.) (2005). *Soil atlas of |
|
| 218 |
#' Europe*. Luxembourg: European Commission, Office for Official Publications |
|
| 219 |
#' of the European Communities. 128 pp. ISBN: 92-894-8120-X. |
|
| 220 |
#' |
|
| 221 |
#' Tol, P. (2021). *Colour Schemes*. SRON. Technical Note No. |
|
| 222 |
#' SRON/EPS/TN/09-002, issue 3.2. |
|
| 223 |
#' URL: \url{https://sronpersonalpages.nl/~pault/data/colourschemes.pdf}
|
|
| 224 |
#' |
|
| 225 |
#' \href{https://www.ccgm.org/}{Commission for the Geological Map of the World}.
|
|
| 226 |
#' @keywords internal |
|
| 227 |
#' @rdname science |
|
| 228 |
#' @name science |
|
| 229 |
NULL |
| 1 |
# HELPERS |
|
| 2 | ||
| 3 |
## https://michaelchirico.github.io/potools/articles/developers.html |
|
| 4 |
tr_ <- function(...) {
|
|
| 5 | 28x |
enc2utf8(gettext(paste0(...), domain = "R-khroma")) |
| 6 |
} |
|
| 7 | ||
| 8 |
`%||%` <- function(x, y) {
|
|
| 9 | 2x |
if (!is.null(x)) x else y |
| 10 |
} |
|
| 11 | ||
| 12 |
assert_package <- function(x) {
|
|
| 13 | 1241x |
if (!requireNamespace(x, quietly = TRUE)) {
|
| 14 | ! |
msg <- tr_("Package %s needed for this function to work. Please install it.")
|
| 15 | ! |
stop(sprintf(msg, sQuote(x)), call. = FALSE) |
| 16 |
} |
|
| 17 | 1241x |
invisible(NULL) |
| 18 |
} |
|
| 19 | ||
| 20 |
assert_color <- function(x) {
|
|
| 21 | 4x |
if (!is.atomic(x) || !is.character(x)) {
|
| 22 | 3x |
msg <- tr_("%s must be a character vector of colors.")
|
| 23 | 3x |
stop(sprintf(msg, sQuote("x")), call. = FALSE)
|
| 24 |
} |
|
| 25 | 1x |
invisible(NULL) |
| 26 |
} |
| 1 |
# Okabe & Ito color scheme |
|
| 2 |
#' @include color.R |
|
| 3 |
NULL |
|
| 4 | ||
| 5 |
# Discrete ===================================================================== |
|
| 6 |
#' Okabe and Ito's Discrete Color Scheme for \pkg{ggplot2} and \pkg{ggraph}
|
|
| 7 |
#' |
|
| 8 |
#' Provides the qualitative color scale from Okabe and Ito 2008. |
|
| 9 |
#' @param ... Arguments passed to [ggplot2::discrete_scale()]. |
|
| 10 |
#' @param reverse A [`logical`] scalar. Should the resulting |
|
| 11 |
#' vector of colors be reversed? |
|
| 12 |
#' @param black_position A [`character`] string giving the position of the black |
|
| 13 |
#' color. It must be one of "`first`" or "`last`". Any unambiguous substring |
|
| 14 |
#' can be given. |
|
| 15 |
#' @param aesthetics A [`character`] string or vector of character |
|
| 16 |
#' strings listing the name(s) of the aesthetic(s) that this scale works with. |
|
| 17 |
#' @details |
|
| 18 |
#' This qualitative color scheme is used as given (no interpolation): |
|
| 19 |
#' colors are picked up to the maximum number of supported values (8). |
|
| 20 |
#' @return A [discrete][ggplot2::discrete_scale] scale. |
|
| 21 |
#' @references |
|
| 22 |
#' Okabe, M. & Ito, K. (2008). *Color Universal Design (CUD): How to Make |
|
| 23 |
#' Figures and Presentations That Are Friendly to Colorblind People*. |
|
| 24 |
#' URL: \url{https://jfly.uni-koeln.de/color/}.
|
|
| 25 |
#' @example inst/examples/ex-okabeito-discrete.R |
|
| 26 |
#' @author N. Frerebeau |
|
| 27 |
#' @family color-blind safe color schemes |
|
| 28 |
#' @family qualitative color schemes |
|
| 29 |
#' @family Okabe and Ito's color scheme |
|
| 30 |
#' @name scale_okabeito_discrete |
|
| 31 |
#' @rdname scale_okabeito_discrete |
|
| 32 |
NULL |
|
| 33 | ||
| 34 |
#' Get Okabe and Ito's Discrete Color Scheme |
|
| 35 |
#' |
|
| 36 |
#' @param black_position A [`character`] string giving the position of the black |
|
| 37 |
#' color. It must be one of "`first`" or "`last`". Any unambiguous substring |
|
| 38 |
#' can be given. |
|
| 39 |
#' @examples |
|
| 40 |
#' get_okabeito_scale("first")
|
|
| 41 |
#' get_okabeito_scale("last")
|
|
| 42 |
#' @keywords internal |
|
| 43 |
#' @noRd |
|
| 44 |
get_okabeito_scale <- function(black_position = c("first", "last")) {
|
|
| 45 | 28x |
black_position <- match.arg(black_position, several.ok = FALSE) |
| 46 | 6x |
switch (black_position, first = "okabeito", last = "okabeitoblack") |
| 47 |
} |
|
| 48 | ||
| 49 |
#' @export |
|
| 50 |
#' @rdname scale_okabeito_discrete |
|
| 51 |
scale_colour_okabeito <- function(..., reverse = FALSE, |
|
| 52 |
black_position = c("first", "last"),
|
|
| 53 |
aesthetics = "colour") {
|
|
| 54 | 14x |
oi_palette <- get_okabeito_scale(black_position) |
| 55 | 14x |
scale_discrete(aesthetics, oi_palette, reverse = reverse, ...) |
| 56 |
} |
|
| 57 | ||
| 58 |
#' @export |
|
| 59 |
#' @rdname scale_okabeito_discrete |
|
| 60 |
scale_color_okabeito <- scale_colour_okabeito |
|
| 61 | ||
| 62 |
#' @export |
|
| 63 |
#' @rdname scale_okabeito_discrete |
|
| 64 |
scale_fill_okabeito <- function(..., reverse = FALSE, |
|
| 65 |
black_position = c("first", "last"),
|
|
| 66 |
aesthetics = "fill") {
|
|
| 67 | 3x |
oi_palette <- get_okabeito_scale(black_position) |
| 68 | 3x |
scale_discrete(aesthetics, oi_palette, reverse = reverse, ...) |
| 69 |
} |
|
| 70 | ||
| 71 |
#' @export |
|
| 72 |
#' @rdname scale_okabeito_discrete |
|
| 73 |
scale_edge_colour_okabeito <- function(..., reverse = FALSE, |
|
| 74 |
black_position = c("first", "last"),
|
|
| 75 |
aesthetics = "edge_colour") {
|
|
| 76 | 8x |
oi_palette <- get_okabeito_scale(black_position) |
| 77 | 8x |
scale_discrete(aesthetics, oi_palette, reverse = reverse, ...) |
| 78 |
} |
|
| 79 | ||
| 80 |
#' @export |
|
| 81 |
#' @rdname scale_okabeito_discrete |
|
| 82 |
scale_edge_color_okabeito <- scale_edge_colour_okabeito |
|
| 83 | ||
| 84 |
#' @export |
|
| 85 |
#' @rdname scale_okabeito_discrete |
|
| 86 |
scale_edge_fill_okabeito <- function(..., reverse = FALSE, |
|
| 87 |
black_position = c("first", "last"),
|
|
| 88 |
aesthetics = "edge_fill") {
|
|
| 89 | 3x |
oi_palette <- get_okabeito_scale(black_position) |
| 90 | 3x |
scale_discrete(aesthetics, oi_palette, reverse = reverse, ...) |
| 91 |
} |
| 1 |
#' Diagnostic Map |
|
| 2 |
#' |
|
| 3 |
#' Produces a diagnostic map for a given color scheme. |
|
| 4 |
#' @param x A [`character`] vector of colors. |
|
| 5 |
#' @param n An [`integer`] specifying the size of the grid (defaults to |
|
| 6 |
#' \eqn{512}).
|
|
| 7 |
#' @return |
|
| 8 |
#' `plot_tiles()` is called for its side-effects: it results in a graphic |
|
| 9 |
#' being displayed (invisibly returns `x`). |
|
| 10 |
#' @example inst/examples/ex-plot.R |
|
| 11 |
#' @author N. Frerebeau |
|
| 12 |
#' @family diagnostic tools |
|
| 13 |
#' @export |
|
| 14 |
plot_tiles <- function(x, n = 512) {
|
|
| 15 |
# Validation |
|
| 16 | 1x |
assert_color(x) |
| 17 | ||
| 18 |
# Save and restore graphical parameters |
|
| 19 | ! |
old_par <- graphics::par(no.readonly = TRUE) |
| 20 | ! |
on.exit(graphics::par(old_par)) |
| 21 | ||
| 22 | ! |
g <- expand.grid( |
| 23 | ! |
x = seq_len(n), |
| 24 | ! |
y = seq_len(n) |
| 25 |
) |
|
| 26 | ! |
noise <- sin(g$x / 16) + cos(g$y / 16) + |
| 27 | ! |
stats::dnorm(sqrt((g$x - 0.75 * n)^2 + (g$y - 0.33 * n)^2) / n * 20) |
| 28 | ! |
z <- matrix(data = noise, nrow = n, ncol = n) |
| 29 | ||
| 30 | ! |
graphics::par(mar = c(0, 0, 0, 0) + 0.1, xaxs = "i", yaxs = "i") |
| 31 | ! |
graphics::image(x = seq_len(n), y = seq_len(n), z = z, col = x, |
| 32 | ! |
axes = FALSE, asp = 1) |
| 33 | ||
| 34 | ! |
invisible(x) |
| 35 |
} |
| 1 |
#' Plot Simulated Color Blindness |
|
| 2 |
#' |
|
| 3 |
#' Shows colors in a plot with different types of simulated color blindness. |
|
| 4 |
#' @param x A [`character`] vector of colors. |
|
| 5 |
#' @return |
|
| 6 |
#' `plot_scheme_colourblind()` is called for its side-effects: it results in a |
|
| 7 |
#' graphic being displayed (invisibly returns `x`). |
|
| 8 |
#' @example inst/examples/ex-change.R |
|
| 9 |
#' @author N. Frerebeau, V. Arel-Bundock |
|
| 10 |
#' @family diagnostic tools |
|
| 11 |
#' @export |
|
| 12 |
plot_scheme_colourblind <- function(x) {
|
|
| 13 |
# Validation |
|
| 14 | ! |
assert_color(x) |
| 15 | ||
| 16 | ! |
n <- length(x) |
| 17 | ! |
col <- c(x, anomalize(x, 'deuteranopia'), anomalize(x, 'protanopia'), |
| 18 | ! |
anomalize(x, 'tritanopia'), anomalize(x, 'achromatopsia')) |
| 19 | ! |
xcoord <- seq(0, 1, length.out = n + 1) |
| 20 | ! |
ycoord <- rep(c(.8, .6, .4, .2, 0), each = n) |
| 21 | ! |
grid::grid.newpage() |
| 22 | ! |
grid::grid.rect( |
| 23 | ! |
x = grid::unit(utils::head(xcoord, -1), "npc"), |
| 24 | ! |
y = grid::unit(ycoord, "npc"), |
| 25 | ! |
width = grid::unit(1 / n, "npc"), |
| 26 | ! |
height = grid::unit(0.7 / 5, "npc"), |
| 27 | ! |
hjust = 0, |
| 28 | ! |
vjust = 0, |
| 29 | ! |
gp = grid::gpar(fill = col, col = col) |
| 30 |
) |
|
| 31 | ! |
grid::grid.text( |
| 32 | ! |
label = c("Palette", "Deuteranopia", "Protanopia", "Tritanopia",
|
| 33 | ! |
"Achromatopsia"), |
| 34 | ! |
x = grid::unit(0, 'npc'), |
| 35 | ! |
y = grid::unit(c(0.97, 0.77, 0.57, 0.37, 0.17), "npc"), |
| 36 | ! |
hjust = 0 |
| 37 |
) |
|
| 38 | ||
| 39 | ! |
invisible(x) |
| 40 |
} |
|
| 41 | ||
| 42 |
#' @rdname plot_scheme_colourblind |
|
| 43 |
#' @export |
|
| 44 |
plot_scheme_colorblind <- plot_scheme_colourblind |
| 1 |
|
|
| 2 | ||
| 3 |
#' @export |
|
| 4 |
print.color_scheme <- function(x, ...) {
|
|
| 5 | ! |
print(unclass(x)) |
| 6 |
} |