diff --git a/DESCRIPTION b/DESCRIPTION index 0f931609d9..bb72103f41 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -208,29 +208,33 @@ Collate: 'position-stack.R' 'quick-plot.R' 'reshape-add-margins.R' + 'reuse-scale.R' 'save.R' 'scale-.R' 'scale-alpha.R' 'scale-binned.R' 'scale-brewer.R' + 'scale-viridis.R' + 'scale-steps.R' + 'scale-manual.R' + 'scale-identity.R' + 'scale-hue.R' + 'scale-grey.R' + 'scale-gradient.R' 'scale-colour.R' + 'scale-colour-ordinal.R' + 'scale-color.R' 'scale-continuous.R' 'scale-date.R' 'scale-discrete-.R' 'scale-expansion.R' - 'scale-gradient.R' - 'scale-grey.R' - 'scale-hue.R' - 'scale-identity.R' + 'scale-fill.R' 'scale-linetype.R' 'scale-linewidth.R' - 'scale-manual.R' 'scale-shape.R' 'scale-size.R' - 'scale-steps.R' 'scale-type.R' 'scale-view.R' - 'scale-viridis.R' 'scales-.R' 'stat-align.R' 'stat-bin.R' @@ -272,5 +276,4 @@ Collate: 'utilities-matrix.R' 'utilities-resolution.R' 'utilities-tidy-eval.R' - 'zxx.R' 'zzz.R' diff --git a/NAMESPACE b/NAMESPACE index 717abb2e18..d63da44ea5 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -486,6 +486,7 @@ export(render_axes) export(render_strips) export(reset_theme_settings) export(resolution) +export(reuse_scale) export(scale_alpha) export(scale_alpha_binned) export(scale_alpha_continuous) diff --git a/R/reuse-scale.R b/R/reuse-scale.R new file mode 100644 index 0000000000..e460778eff --- /dev/null +++ b/R/reuse-scale.R @@ -0,0 +1,16 @@ +#' Make a copy of a color scale for a different aesthetic. +#' Example use: `scale_outlinecolor_hue <- reuse_scale(scale_color_hue, "outlinecolor")` +#' @param scale A color scale to copy from +#' @param aesthetic The name of the new aesthetic or aesthetics to apply the color scale to +#' @export +reuse_scale <- function(scale, aesthetics) { + check_function(scale) + if (!"aesthetics" %in% fn_fmls_names(scale)) { + cli::cli_abort(c( + "The {.arg {deparse(substitute(scale))}} function must have an {.arg aesthetics} argument.", + i = "{.fn {deparse(substitute(scale))}} does not have that argument." + )) + } + formals(scale)$aesthetics <- aesthetics + scale +} diff --git a/R/scale-brewer.R b/R/scale-brewer.R index b3d48ab820..898e6185e7 100644 --- a/R/scale-brewer.R +++ b/R/scale-brewer.R @@ -8,7 +8,7 @@ #' #' @note #' The `distiller` scales extend `brewer` scales by smoothly -#' interpolating 7 colours from any palette to a continuous scale. +#' interpolating 7 colours from any palette to a continuous scale. #' The `distiller` scales have a default direction = -1. To reverse, use direction = 1. #' The `fermenter` scales provide binned versions of the `brewer` scales. #' @@ -86,12 +86,6 @@ scale_colour_brewer <- function(..., type = "seq", palette = 1, direction = 1, a discrete_scale(aesthetics, palette = brewer_pal(type, palette, direction), ...) } -#' @export -#' @rdname scale_brewer -scale_fill_brewer <- function(..., type = "seq", palette = 1, direction = 1, aesthetics = "fill") { - discrete_scale(aesthetics, palette = brewer_pal(type, palette, direction), ...) -} - #' @export #' @rdname scale_brewer scale_colour_distiller <- function(..., type = "seq", palette = 1, direction = -1, values = NULL, space = "Lab", na.value = "grey50", guide = "colourbar", aesthetics = "colour") { @@ -112,23 +106,6 @@ scale_colour_distiller <- function(..., type = "seq", palette = 1, direction = - # For diverging scales, you need an odd number to make sure the mid-point is in the center } -#' @export -#' @rdname scale_brewer -scale_fill_distiller <- function(..., type = "seq", palette = 1, direction = -1, values = NULL, space = "Lab", na.value = "grey50", guide = "colourbar", aesthetics = "fill") { - type <- arg_match0(type, c("seq", "div", "qual")) - if (type == "qual") { - cli::cli_warn(c( - "Using a discrete colour palette in a continuous scale", - "i" = "Consider using {.code type = \"seq\"} or {.code type = \"div\"} instead" - )) - } - continuous_scale( - aesthetics, - palette = gradient_n_pal(brewer_pal(type, palette, direction)(7), values, space), - na.value = na.value, guide = guide, ... - ) -} - #' @export #' @rdname scale_brewer scale_colour_fermenter <- function(..., type = "seq", palette = 1, direction = -1, na.value = "grey50", guide = "coloursteps", aesthetics = "colour") { @@ -142,16 +119,3 @@ scale_colour_fermenter <- function(..., type = "seq", palette = 1, direction = - } binned_scale(aesthetics, palette = binned_pal(brewer_pal(type, palette, direction)), na.value = na.value, guide = guide, ...) } - -#' @export -#' @rdname scale_brewer -scale_fill_fermenter <- function(..., type = "seq", palette = 1, direction = -1, na.value = "grey50", guide = "coloursteps", aesthetics = "fill") { - type <- arg_match0(type, c("seq", "div", "qual")) - if (type == "qual") { - cli::cli_warn(c( - "Using a discrete colour palette in a binned scale", - "i" = "Consider using {.code type = \"seq\"} or {.code type = \"div\"} instead" - )) - } - binned_scale(aesthetics, palette = binned_pal(brewer_pal(type, palette, direction)), na.value = na.value, guide = guide, ...) -} diff --git a/R/scale-color.R b/R/scale-color.R new file mode 100644 index 0000000000..d0458fff3a --- /dev/null +++ b/R/scale-color.R @@ -0,0 +1,115 @@ +#' @include scale-brewer.R scale-colour-ordinal.R scale-colour.R scale-gradient.R scale-grey.R scale-hue.R scale-identity.R scale-manual.R scale-steps.R scale-viridis.R +NULL + + +# British to American spellings ---------------------------------------------- + +#' @export +#' @rdname scale_brewer +#' @usage NULL +scale_color_brewer <- scale_colour_brewer + +#' @export +#' @rdname scale_brewer +#' @usage NULL +scale_color_distiller <- scale_colour_distiller + +#' @export +#' @rdname scale_brewer +#' @usage NULL +scale_color_fermenter <- scale_colour_fermenter + +#' @export +#' @rdname scale_colour_continuous +#' @usage NULL +scale_color_continuous <- scale_colour_continuous + +#' @export +#' @rdname scale_colour_continuous +#' @usage NULL +scale_color_binned <- scale_colour_binned + +#' @export +#' @rdname scale_colour_discrete +#' @usage NULL +scale_color_discrete <- scale_colour_discrete + +#' @export +#' @rdname scale_gradient +#' @usage NULL +scale_color_gradient <- scale_colour_gradient + +#' @export +#' @rdname scale_gradient +#' @usage NULL +scale_color_gradient2 <- scale_colour_gradient2 + +#' @export +#' @rdname scale_gradient +#' @usage NULL +scale_color_gradientn <- scale_colour_gradientn + +#' @export +#' @rdname scale_steps +#' @usage NULL +scale_color_steps <- scale_colour_steps + +#' @export +#' @rdname scale_steps +#' @usage NULL +scale_color_steps2 <- scale_colour_steps2 + +#' @export +#' @rdname scale_steps +#' @usage NULL +scale_color_stepsn <- scale_colour_stepsn + +#' @export +#' @rdname scale_grey +#' @usage NULL +scale_color_grey <- scale_colour_grey + +#' @export +#' @rdname scale_hue +#' @usage NULL +scale_color_hue <- scale_colour_hue + +#' @export +#' @rdname scale_identity +#' @usage NULL +scale_color_identity <- scale_colour_identity + +#' @export +#' @rdname scale_manual +#' @usage NULL +scale_color_manual <- scale_colour_manual + +#' @export +#' @rdname scale_viridis +#' @usage NULL +scale_color_viridis_d <- scale_colour_viridis_d + +#' @export +#' @rdname scale_viridis +#' @usage NULL +scale_color_viridis_c <- scale_colour_viridis_c + +#' @export +#' @rdname scale_viridis +#' @usage NULL +scale_color_viridis_b <- scale_colour_viridis_b + +#' @export +#' @rdname scale_viridis +#' @usage NULL +scale_color_ordinal <- scale_colour_ordinal + +#' @export +#' @rdname scale_gradient +#' @usage NULL +scale_color_datetime <- scale_colour_datetime + +#' @export +#' @rdname scale_gradient +#' @usage NULL +scale_color_date <- scale_colour_date diff --git a/R/scale-colour-ordinal.R b/R/scale-colour-ordinal.R new file mode 100644 index 0000000000..474cb84112 --- /dev/null +++ b/R/scale-colour-ordinal.R @@ -0,0 +1,72 @@ +#' @include scale-viridis.R + +# Default scales ------------------------------------------------------------- + +#' @export +#' @rdname scale_viridis +#' @usage NULL +scale_colour_ordinal <- function(..., aesthetics = "colour", type = getOption(glue("ggplot2.ordinal.{aesthetics[1]}"))) { + type <- type %||% scale_colour_viridis_d + args <- list2(...) + args$call <- args$call %||% current_call() + if (is.function(type)) { + if (any(c("...", "call") %in% fn_fmls_names(type))) { + args$call <- args$call %||% current_call() + } + exec(type, !!!args, aesthetics = aesthetics) + } else { + exec( + discrete_scale, + aesthetics = aesthetics, + palette = ordinal_pal(type), + !!!args + ) + } +} + +#' @export +#' @rdname scale_gradient +#' @usage NULL +scale_colour_datetime <- function(..., + aesthetics = "colour", + low = "#132B43", + high = "#56B1F7", + space = "Lab", + na.value = "grey50", + guide = "colourbar") { + datetime_scale( + aesthetics, + "time", + palette = seq_gradient_pal(low, high, space), + na.value = na.value, + guide = guide, + ... + ) +} + +#' @export +#' @rdname scale_gradient +#' @usage NULL +scale_colour_date <- function(..., + aesthetics = "colour", + low = "#132B43", + high = "#56B1F7", + space = "Lab", + na.value = "grey50", + guide = "colourbar") { + datetime_scale( + aesthetics, + "date", + palette = seq_gradient_pal(low, high, space), + na.value = na.value, + guide = guide, + ... + ) +} + +ordinal_pal <- function(colours, na.color = "grey50", alpha = TRUE) { + pal <- scales::colour_ramp(colours, na.color = na.color, alpha = alpha) + function(n) { + pal(seq(0, 1, length.out = n)) + } +} diff --git a/R/scale-colour.R b/R/scale-colour.R index a3084ec7df..3e4de63e59 100644 --- a/R/scale-colour.R +++ b/R/scale-colour.R @@ -75,10 +75,10 @@ #' v #' options(ggplot2.continuous.fill = tmp) # restore previous setting #' @export -scale_colour_continuous <- function(..., - type = getOption("ggplot2.continuous.colour")) { +scale_colour_continuous <- function(..., aesthetics = "colour", + type = getOption(glue("ggplot2.continuous.{aesthetics[1]}"))) { type <- type %||% "gradient" - args <- list2(...) + args <- list2(..., aesthetics = aesthetics) args$call <- args$call %||% current_call() if (is.function(type)) { @@ -98,36 +98,11 @@ scale_colour_continuous <- function(..., } } -#' @rdname scale_colour_continuous -#' @export -scale_fill_continuous <- function(..., - type = getOption("ggplot2.continuous.fill")) { - type <- type %||% "gradient" - args <- list2(...) - args$call <- args$call %||% current_call() - - if (is.function(type)) { - if (!any(c("...", "call") %in% fn_fmls_names(type))) { - args$call <- NULL - } - check_scale_type(exec(type, !!!args), "scale_fill_continuous", "fill") - } else if (identical(type, "gradient")) { - exec(scale_fill_gradient, !!!args) - } else if (identical(type, "viridis")) { - exec(scale_fill_viridis_c, !!!args) - } else { - cli::cli_abort(c( - "Unknown scale type: {.val {type}}", - "i" = "Use either {.val gradient} or {.val viridis}" - )) - } -} - #' @export #' @rdname scale_colour_continuous -scale_colour_binned <- function(..., - type = getOption("ggplot2.binned.colour")) { - args <- list2(...) +scale_colour_binned <- function(..., aesthetics = "colour", + type = getOption(glue("ggplot2.binned.{aesthetics[1]}"))) { + args <- list2(..., aesthetics = aesthetics) args$call <- args$call %||% current_call() if (is.function(type)) { if (!any(c("...", "call") %in% fn_fmls_names(type))) { @@ -135,7 +110,7 @@ scale_colour_binned <- function(..., } check_scale_type(exec(type, !!!args), "scale_colour_binned", "colour") } else { - type_fallback <- getOption("ggplot2.continuous.colour", default = "gradient") + type_fallback <- getOption(glue("ggplot2.continuous.{aesthetics[1]}"), default = "gradient") # don't use fallback from scale_colour_continuous() if it is # a function, since that would change the type of the color # scale from binned to continuous @@ -157,40 +132,6 @@ scale_colour_binned <- function(..., } } -#' @export -#' @rdname scale_colour_continuous -scale_fill_binned <- function(..., - type = getOption("ggplot2.binned.fill")) { - args <- list2(...) - args$call <- args$call %||% current_call() - if (is.function(type)) { - if (!any(c("...", "call") %in% fn_fmls_names(type))) { - args$call <- NULL - } - check_scale_type(exec(type, !!!args), "scale_fill_binned", "fill") - } else { - type_fallback <- getOption("ggplot2.continuous.fill", default = "gradient") - # don't use fallback from scale_colour_continuous() if it is - # a function, since that would change the type of the color - # scale from binned to continuous - if (is.function(type_fallback)) { - type_fallback <- "gradient" - } - type <- type %||% type_fallback - - if (identical(type, "gradient")) { - exec(scale_fill_steps, !!!args) - } else if (identical(type, "viridis")) { - exec(scale_fill_viridis_b, !!!args) - } else { - cli::cli_abort(c( - "Unknown scale type: {.val {type}}", - "i" = "Use either {.val gradient} or {.val viridis}" - )) - } - } -} - # helper function to make sure that the provided scale is of the correct # type (i.e., is continuous and works with the provided aesthetic) diff --git a/R/scale-fill.R b/R/scale-fill.R new file mode 100644 index 0000000000..16186d8b57 --- /dev/null +++ b/R/scale-fill.R @@ -0,0 +1,101 @@ +#' @include scale-brewer.R scale-colour-ordinal.R scale-colour.R scale-gradient.R scale-grey.R scale-hue.R scale-identity.R scale-manual.R scale-steps.R scale-viridis.R +NULL + + +## general color scales --------------------------- + +#' @export +#' @rdname scale_colour_continuous +scale_fill_binned <- reuse_scale(scale_colour_binned, "fill") + +#' @export +#' @rdname scale_colour_continuous +scale_fill_continuous <- reuse_scale(scale_colour_continuous, "fill") + +#' @export +#' @rdname scale_gradient +#' @usage NULL +scale_fill_datetime <- reuse_scale(scale_colour_datetime, "fill") + +#' @export +#' @rdname scale_gradient +#' @usage NULL +scale_fill_date <- reuse_scale(scale_colour_date, "fill") + +#' @export +#' @rdname scale_colour_discrete +scale_fill_discrete <- reuse_scale(scale_colour_discrete, "fill") + +#' @export +#' @rdname scale_identity +scale_fill_identity <- reuse_scale(scale_colour_identity, "fill") + +#' @export +#' @rdname scale_manual +scale_fill_manual <- reuse_scale(scale_colour_manual, "fill") + +#' @export +#' @rdname scale_viridis +#' @usage NULL +scale_fill_ordinal <- reuse_scale(scale_colour_ordinal, "fill") + +scale_fill_qualitative <- reuse_scale(scale_colour_qualitative, "fill") + + +## specific color scales -------------------------- + +#' @export +#' @rdname scale_brewer +scale_fill_brewer <- reuse_scale(scale_colour_brewer, "fill") + +#' @export +#' @rdname scale_brewer +scale_fill_distiller <- reuse_scale(scale_colour_distiller, "fill") + +#' @export +#' @rdname scale_brewer +scale_fill_fermenter <- reuse_scale(scale_colour_fermenter, "fill") + +#' @export +#' @rdname scale_gradient +scale_fill_gradient <- reuse_scale(scale_colour_gradient, "fill") + +#' @export +#' @rdname scale_gradient +scale_fill_gradient2 <- reuse_scale(scale_colour_gradient2, "fill") + +#' @export +#' @rdname scale_gradient +scale_fill_gradientn <- reuse_scale(scale_colour_gradientn, "fill") + +#' @export +#' @rdname scale_grey +scale_fill_grey <- reuse_scale(scale_colour_grey, "fill") + +#' @export +#' @rdname scale_hue +scale_fill_hue <- reuse_scale(scale_colour_hue, "fill") + +#' @export +#' @rdname scale_steps +scale_fill_steps <- reuse_scale(scale_colour_steps, "fill") + +#' @export +#' @rdname scale_steps +scale_fill_steps2 <- reuse_scale(scale_colour_steps2, "fill") + +#' @export +#' @rdname scale_steps +scale_fill_stepsn <- reuse_scale(scale_colour_stepsn, "fill") + +#' @export +#' @rdname scale_viridis +scale_fill_viridis_b <- reuse_scale(scale_colour_viridis_b, "fill") + +#' @export +#' @rdname scale_viridis +scale_fill_viridis_c <- reuse_scale(scale_colour_viridis_c, "fill") + +#' @export +#' @rdname scale_viridis +scale_fill_viridis_d <- reuse_scale(scale_colour_viridis_d, "fill") diff --git a/R/scale-gradient.R b/R/scale-gradient.R index 95ee2824b2..e06efda371 100644 --- a/R/scale-gradient.R +++ b/R/scale-gradient.R @@ -77,15 +77,7 @@ #' scale_colour_gradient <- function(..., low = "#132B43", high = "#56B1F7", space = "Lab", na.value = "grey50", guide = "colourbar", aesthetics = "colour") { - continuous_scale(aesthetics, palette = seq_gradient_pal(low, high, space), - na.value = na.value, guide = guide, ...) -} - -#' @rdname scale_gradient -#' @export -scale_fill_gradient <- function(..., low = "#132B43", high = "#56B1F7", space = "Lab", - na.value = "grey50", guide = "colourbar", aesthetics = "fill") { - continuous_scale(aesthetics, palette = seq_gradient_pal(low, high, space), + continuous_scale(aesthetics = aesthetics, palette = seq_gradient_pal(low, high, space), na.value = na.value, guide = guide, ...) } @@ -98,20 +90,7 @@ scale_colour_gradient2 <- function(..., low = muted("red"), mid = "white", high midpoint = 0, space = "Lab", na.value = "grey50", guide = "colourbar", aesthetics = "colour") { continuous_scale( - aesthetics, - palette = div_gradient_pal(low, mid, high, space), - na.value = na.value, guide = guide, ..., - rescaler = mid_rescaler(mid = midpoint) - ) -} - -#' @rdname scale_gradient -#' @export -scale_fill_gradient2 <- function(..., low = muted("red"), mid = "white", high = muted("blue"), - midpoint = 0, space = "Lab", na.value = "grey50", guide = "colourbar", - aesthetics = "fill") { - continuous_scale( - aesthetics, + aesthetics = aesthetics, palette = div_gradient_pal(low, mid, high, space), na.value = na.value, guide = guide, ..., rescaler = mid_rescaler(mid = midpoint) @@ -133,19 +112,7 @@ scale_colour_gradientn <- function(..., colours, values = NULL, space = "Lab", n colours <- if (missing(colours)) colors else colours continuous_scale( - aesthetics, - palette = gradient_n_pal(colours, values, space), - na.value = na.value, guide = guide, ... - ) -} -#' @rdname scale_gradient -#' @export -scale_fill_gradientn <- function(..., colours, values = NULL, space = "Lab", na.value = "grey50", - guide = "colourbar", aesthetics = "fill", colors) { - colours <- if (missing(colours)) colors else colours - - continuous_scale( - aesthetics, + aesthetics = aesthetics, palette = gradient_n_pal(colours, values, space), na.value = na.value, guide = guide, ... ) diff --git a/R/scale-grey.R b/R/scale-grey.R index c71dd444ef..382ff52136 100644 --- a/R/scale-grey.R +++ b/R/scale-grey.R @@ -31,10 +31,3 @@ scale_colour_grey <- function(..., start = 0.2, end = 0.8, na.value = "red", aes discrete_scale(aesthetics, palette = grey_pal(start, end), na.value = na.value, ...) } - -#' @rdname scale_grey -#' @export -scale_fill_grey <- function(..., start = 0.2, end = 0.8, na.value = "red", aesthetics = "fill") { - discrete_scale(aesthetics, palette = grey_pal(start, end), - na.value = na.value, ...) -} diff --git a/R/scale-hue.R b/R/scale-hue.R index 0e0d796537..d4e2a78087 100644 --- a/R/scale-hue.R +++ b/R/scale-hue.R @@ -55,15 +55,7 @@ #' } scale_colour_hue <- function(..., h = c(0, 360) + 15, c = 100, l = 65, h.start = 0, direction = 1, na.value = "grey50", aesthetics = "colour") { - discrete_scale(aesthetics, palette = hue_pal(h, c, l, h.start, direction), - na.value = na.value, ...) -} - -#' @rdname scale_hue -#' @export -scale_fill_hue <- function(..., h = c(0, 360) + 15, c = 100, l = 65, h.start = 0, - direction = 1, na.value = "grey50", aesthetics = "fill") { - discrete_scale(aesthetics, palette = hue_pal(h, c, l, h.start, direction), + discrete_scale(aesthetics = aesthetics, palette = hue_pal(h, c, l, h.start, direction), na.value = na.value, ...) } @@ -121,10 +113,10 @@ scale_fill_hue <- function(..., h = c(0, 360) + 15, c = 100, l = 65, h.start = 0 #' print(cty_by_var(fl)) #' }) #' -scale_colour_discrete <- function(..., type = getOption("ggplot2.discrete.colour")) { +scale_colour_discrete <- function(..., aesthetics = "colour", type = getOption(glue("ggplot2.discrete.{aesthetics[1]}"))) { # TODO: eventually `type` should default to a set of colour-blind safe color codes (e.g. Okabe-Ito) - type <- type %||% scale_colour_hue - args <- list2(...) + type <- type %||% "hue" + args <- list2(..., aesthetics = aesthetics) args$call <- args$call %||% current_call() if (is.function(type)) { @@ -142,41 +134,10 @@ scale_colour_discrete <- function(..., type = getOption("ggplot2.discrete.colour } } -#' @rdname scale_colour_discrete -#' @export -scale_fill_discrete <- function(..., type = getOption("ggplot2.discrete.fill")) { - # TODO: eventually `type` should default to a set of colour-blind safe color codes (e.g. Okabe-Ito) - type <- type %||% scale_fill_hue - args <- list2(...) - args$call <- args$call %||% current_call() - - if (is.function(type)) { - if (!any(c("...", "call") %in% fn_fmls_names(type))) { - args$call <- NULL - } - check_scale_type( - exec(type, !!!args), - "scale_fill_discrete", - "fill", - scale_is_discrete = TRUE - ) - } else { - exec(scale_fill_qualitative, !!!args, type = type) - } -} - scale_colour_qualitative <- function(..., type = NULL, h = c(0, 360) + 15, c = 100, l = 65, h.start = 0, direction = 1, na.value = "grey50", aesthetics = "colour") { discrete_scale( - aesthetics, palette = qualitative_pal(type, h, c, l, h.start, direction), - na.value = na.value, ... - ) -} - -scale_fill_qualitative <- function(..., type = NULL, h = c(0, 360) + 15, c = 100, l = 65, h.start = 0, - direction = 1, na.value = "grey50", aesthetics = "fill") { - discrete_scale( - aesthetics, palette = qualitative_pal(type, h, c, l, h.start, direction), + aesthetics = aesthetics, palette = qualitative_pal(type, h, c, l, h.start, direction), na.value = na.value, ... ) } diff --git a/R/scale-identity.R b/R/scale-identity.R index 9a3ace41a0..9d5cb9bafc 100644 --- a/R/scale-identity.R +++ b/R/scale-identity.R @@ -63,16 +63,7 @@ NULL #' @rdname scale_identity #' @export scale_colour_identity <- function(..., guide = "none", aesthetics = "colour") { - sc <- discrete_scale(aesthetics, palette = identity_pal(), ..., guide = guide, - super = ScaleDiscreteIdentity) - - sc -} - -#' @rdname scale_identity -#' @export -scale_fill_identity <- function(..., guide = "none", aesthetics = "fill") { - sc <- discrete_scale(aesthetics, palette = identity_pal(), ..., guide = guide, + sc <- discrete_scale(aesthetics = aesthetics, palette = identity_pal(), ..., guide = guide, super = ScaleDiscreteIdentity) sc diff --git a/R/scale-manual.R b/R/scale-manual.R index 380d64d64f..b24db5c8da 100644 --- a/R/scale-manual.R +++ b/R/scale-manual.R @@ -88,13 +88,7 @@ NULL #' @rdname scale_manual #' @export scale_colour_manual <- function(..., values, aesthetics = "colour", breaks = waiver(), na.value = "grey50") { - manual_scale(aesthetics, values, breaks, ..., na.value = na.value) -} - -#' @rdname scale_manual -#' @export -scale_fill_manual <- function(..., values, aesthetics = "fill", breaks = waiver(), na.value = "grey50") { - manual_scale(aesthetics, values, breaks, ..., na.value = na.value) + manual_scale(aesthetics = aesthetics, values, breaks, ..., na.value = na.value) } #' @rdname scale_manual diff --git a/R/scale-steps.R b/R/scale-steps.R index 5bbba07cb9..1b20420eeb 100644 --- a/R/scale-steps.R +++ b/R/scale-steps.R @@ -46,7 +46,7 @@ #' @rdname scale_steps scale_colour_steps <- function(..., low = "#132B43", high = "#56B1F7", space = "Lab", na.value = "grey50", guide = "coloursteps", aesthetics = "colour") { - binned_scale(aesthetics, palette = seq_gradient_pal(low, high, space), + binned_scale(aesthetics = aesthetics, palette = seq_gradient_pal(low, high, space), na.value = na.value, guide = guide, ...) } #' @rdname scale_steps @@ -54,7 +54,7 @@ scale_colour_steps <- function(..., low = "#132B43", high = "#56B1F7", space = " scale_colour_steps2 <- function(..., low = muted("red"), mid = "white", high = muted("blue"), midpoint = 0, space = "Lab", na.value = "grey50", guide = "coloursteps", aesthetics = "colour") { - binned_scale(aesthetics, palette = div_gradient_pal(low, mid, high, space), + binned_scale(aesthetics = aesthetics, palette = div_gradient_pal(low, mid, high, space), na.value = na.value, guide = guide, rescaler = mid_rescaler(mid = midpoint), ...) } #' @rdname scale_steps @@ -62,29 +62,6 @@ scale_colour_steps2 <- function(..., low = muted("red"), mid = "white", high = m scale_colour_stepsn <- function(..., colours, values = NULL, space = "Lab", na.value = "grey50", guide = "coloursteps", aesthetics = "colour", colors) { colours <- if (missing(colours)) colors else colours - binned_scale(aesthetics, palette = gradient_n_pal(colours, values, space), - na.value = na.value, guide = guide, ...) -} -#' @rdname scale_steps -#' @export -scale_fill_steps <- function(..., low = "#132B43", high = "#56B1F7", space = "Lab", - na.value = "grey50", guide = "coloursteps", aesthetics = "fill") { - binned_scale(aesthetics, palette = seq_gradient_pal(low, high, space), - na.value = na.value, guide = guide, ...) -} -#' @rdname scale_steps -#' @export -scale_fill_steps2 <- function(..., low = muted("red"), mid = "white", high = muted("blue"), - midpoint = 0, space = "Lab", na.value = "grey50", guide = "coloursteps", - aesthetics = "fill") { - binned_scale(aesthetics, palette = div_gradient_pal(low, mid, high, space), - na.value = na.value, guide = guide, rescaler = mid_rescaler(mid = midpoint), ...) -} -#' @rdname scale_steps -#' @export -scale_fill_stepsn <- function(..., colours, values = NULL, space = "Lab", na.value = "grey50", - guide = "coloursteps", aesthetics = "fill", colors) { - colours <- if (missing(colours)) colors else colours - binned_scale(aesthetics, palette = gradient_n_pal(colours, values, space), + binned_scale(aesthetics = aesthetics, palette = gradient_n_pal(colours, values, space), na.value = na.value, guide = guide, ...) } diff --git a/R/scale-viridis.R b/R/scale-viridis.R index 72ecd4a491..9fbd2e7203 100644 --- a/R/scale-viridis.R +++ b/R/scale-viridis.R @@ -67,17 +67,6 @@ scale_colour_viridis_d <- function(..., alpha = 1, begin = 0, end = 1, ) } -#' @export -#' @rdname scale_viridis -scale_fill_viridis_d <- function(..., alpha = 1, begin = 0, end = 1, - direction = 1, option = "D", aesthetics = "fill") { - discrete_scale( - aesthetics, - palette = viridis_pal(alpha, begin, end, direction, option), - ... - ) -} - #' @export #' @rdname scale_viridis scale_colour_viridis_c <- function(..., alpha = 1, begin = 0, end = 1, @@ -97,25 +86,6 @@ scale_colour_viridis_c <- function(..., alpha = 1, begin = 0, end = 1, ) } -#' @export -#' @rdname scale_viridis -scale_fill_viridis_c <- function(..., alpha = 1, begin = 0, end = 1, - direction = 1, option = "D", values = NULL, - space = "Lab", na.value = "grey50", - guide = "colourbar", aesthetics = "fill") { - continuous_scale( - aesthetics, - palette = gradient_n_pal( - viridis_pal(alpha, begin, end, direction, option)(6), - values, - space - ), - na.value = na.value, - guide = guide, - ... - ) -} - #' @export #' @rdname scale_viridis scale_colour_viridis_b <- function(..., alpha = 1, begin = 0, end = 1, @@ -134,22 +104,3 @@ scale_colour_viridis_b <- function(..., alpha = 1, begin = 0, end = 1, ... ) } - -#' @export -#' @rdname scale_viridis -scale_fill_viridis_b <- function(..., alpha = 1, begin = 0, end = 1, - direction = 1, option = "D", values = NULL, - space = "Lab", na.value = "grey50", - guide = "coloursteps", aesthetics = "fill") { - pal <- binned_pal( - viridis_pal(alpha, begin, end, direction, option) - ) - - binned_scale( - aesthetics, - palette = pal, - na.value = na.value, - guide = guide, - ... - ) -} diff --git a/R/zxx.R b/R/zxx.R deleted file mode 100644 index 369f7c532c..0000000000 --- a/R/zxx.R +++ /dev/null @@ -1,244 +0,0 @@ -# Default scales ------------------------------------------------------------- - -#' @export -#' @rdname scale_viridis -#' @usage NULL -scale_colour_ordinal <- function(..., type = getOption("ggplot2.ordinal.colour", getOption("ggplot2.ordinal.fill"))) { - type <- type %||% scale_colour_viridis_d - args <- list2(...) - args$call <- args$call %||% current_call() - if (is.function(type)) { - if (any(c("...", "call") %in% fn_fmls_names(type))) { - args$call <- args$call %||% current_call() - } - exec(type, !!!args) - } else { - exec( - discrete_scale, - aesthetics = "colour", - palette = ordinal_pal(type), - !!!args - ) - } -} - - -#' @export -#' @rdname scale_viridis -#' @usage NULL -scale_color_ordinal <- scale_colour_ordinal - -#' @export -#' @rdname scale_gradient -#' @usage NULL -scale_colour_datetime <- function(..., - low = "#132B43", - high = "#56B1F7", - space = "Lab", - na.value = "grey50", - guide = "colourbar") { - datetime_scale( - "colour", - "time", - palette = seq_gradient_pal(low, high, space), - na.value = na.value, - guide = guide, - ... - ) -} - -#' @export -#' @rdname scale_gradient -#' @usage NULL -scale_color_datetime <- scale_colour_datetime - -#' @export -#' @rdname scale_gradient -#' @usage NULL -scale_colour_date <- function(..., - low = "#132B43", - high = "#56B1F7", - space = "Lab", - na.value = "grey50", - guide = "colourbar") { - datetime_scale( - "colour", - "date", - palette = seq_gradient_pal(low, high, space), - na.value = na.value, - guide = guide, - ... - ) -} - - -#' @export -#' @rdname scale_gradient -#' @usage NULL -scale_color_date <- scale_colour_date - -#' @export -#' @rdname scale_viridis -#' @usage NULL -scale_fill_ordinal <- function(..., type = getOption("ggplot2.ordinal.fill", getOption("ggplot2.ordinal.colour"))) { - type <- type %||% scale_fill_viridis_d - args <- list2(...) - args$call <- args$call %||% current_call() - - if (is.function(type)) { - if (any(c("...", "call") %in% fn_fmls_names(type))) { - args$call <- args$call %||% current_call() - } - exec(type, !!!args) - } else { - exec( - discrete_scale, - aesthetics = "fill", - palette = ordinal_pal(type), - !!!args - ) - } -} - -ordinal_pal <- function(colours, na.color = "grey50", alpha = TRUE) { - pal <- scales::colour_ramp(colours, na.color = na.color, alpha = alpha) - function(n) { - pal(seq(0, 1, length.out = n)) - } -} - -#' @export -#' @rdname scale_gradient -#' @usage NULL -scale_fill_datetime <- function(..., - low = "#132B43", - high = "#56B1F7", - space = "Lab", - na.value = "grey50", - guide = "colourbar") { - datetime_scale( - "fill", - "time", - palette = seq_gradient_pal(low, high, space), - na.value = na.value, - guide = guide, - ... - ) -} - -#' @export -#' @rdname scale_gradient -#' @usage NULL -scale_fill_date <- function(..., - low = "#132B43", - high = "#56B1F7", - space = "Lab", - na.value = "grey50", - guide = "colourbar") { - datetime_scale( - "fill", - "date", - palette = seq_gradient_pal(low, high, space), - na.value = na.value, - guide = guide, - ... - ) -} - - -# British to American spellings ---------------------------------------------- - -#' @export -#' @rdname scale_brewer -#' @usage NULL -scale_color_brewer <- scale_colour_brewer - -#' @export -#' @rdname scale_brewer -#' @usage NULL -scale_color_distiller <- scale_colour_distiller - -#' @export -#' @rdname scale_brewer -#' @usage NULL -scale_color_fermenter <- scale_colour_fermenter - -#' @export -#' @rdname scale_colour_continuous -#' @usage NULL -scale_color_continuous <- scale_colour_continuous - -#' @export -#' @rdname scale_colour_continuous -#' @usage NULL -scale_color_binned <- scale_colour_binned - -#' @export -#' @rdname scale_colour_discrete -#' @usage NULL -scale_color_discrete <- scale_colour_discrete - -#' @export -#' @rdname scale_gradient -#' @usage NULL -scale_color_gradient <- scale_colour_gradient - -#' @export -#' @rdname scale_gradient -#' @usage NULL -scale_color_gradient2 <- scale_colour_gradient2 - -#' @export -#' @rdname scale_gradient -#' @usage NULL -scale_color_gradientn <- scale_colour_gradientn - -#' @export -#' @rdname scale_steps -#' @usage NULL -scale_color_steps <- scale_colour_steps - -#' @export -#' @rdname scale_steps -#' @usage NULL -scale_color_steps2 <- scale_colour_steps2 - -#' @export -#' @rdname scale_steps -#' @usage NULL -scale_color_stepsn <- scale_colour_stepsn - -#' @export -#' @rdname scale_grey -#' @usage NULL -scale_color_grey <- scale_colour_grey - -#' @export -#' @rdname scale_hue -#' @usage NULL -scale_color_hue <- scale_colour_hue - -#' @export -#' @rdname scale_identity -#' @usage NULL -scale_color_identity <- scale_colour_identity - -#' @export -#' @rdname scale_manual -#' @usage NULL -scale_color_manual <- scale_colour_manual - -#' @export -#' @rdname scale_viridis -#' @usage NULL -scale_color_viridis_d <- scale_colour_viridis_d - -#' @export -#' @rdname scale_viridis -#' @usage NULL -scale_color_viridis_c <- scale_colour_viridis_c - -#' @export -#' @rdname scale_viridis -#' @usage NULL -scale_color_viridis_b <- scale_colour_viridis_b diff --git a/man/ggplot2-ggproto.Rd b/man/ggplot2-ggproto.Rd index 37a042dd68..26dfcfef36 100644 --- a/man/ggplot2-ggproto.Rd +++ b/man/ggplot2-ggproto.Rd @@ -17,8 +17,8 @@ % R/guide-none.R, R/guide-old.R, R/layout.R, R/position-.R, % R/position-dodge.R, R/position-dodge2.R, R/position-identity.R, % R/position-jitter.R, R/position-jitterdodge.R, R/position-nudge.R, -% R/position-stack.R, R/scale-.R, R/scale-binned.R, R/scale-continuous.R, -% R/scale-date.R, R/scale-discrete-.R, R/scale-identity.R, R/stat-align.R, +% R/position-stack.R, R/scale-.R, R/scale-binned.R, R/scale-identity.R, +% R/scale-continuous.R, R/scale-date.R, R/scale-discrete-.R, R/stat-align.R, % R/stat-bin.R, R/stat-bin2d.R, R/stat-bindot.R, R/stat-binhex.R, % R/stat-boxplot.R, R/stat-contour.R, R/stat-count.R, R/stat-density-2d.R, % R/stat-density.R, R/stat-ecdf.R, R/stat-ellipse.R, R/stat-function.R, @@ -110,12 +110,12 @@ \alias{ScaleDiscrete} \alias{ScaleBinned} \alias{ScaleBinnedPosition} +\alias{ScaleDiscreteIdentity} +\alias{ScaleContinuousIdentity} \alias{ScaleContinuousPosition} \alias{ScaleContinuousDatetime} \alias{ScaleContinuousDate} \alias{ScaleDiscretePosition} -\alias{ScaleDiscreteIdentity} -\alias{ScaleContinuousIdentity} \alias{StatAlign} \alias{StatBin} \alias{StatBin2d} diff --git a/man/reuse_scale.Rd b/man/reuse_scale.Rd new file mode 100644 index 0000000000..757689ffd8 --- /dev/null +++ b/man/reuse_scale.Rd @@ -0,0 +1,18 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/reuse-scale.R +\name{reuse_scale} +\alias{reuse_scale} +\title{Make a copy of a color scale for a different aesthetic. +Example use: \code{scale_outlinecolor_hue <- reuse_scale(scale_color_hue, "outlinecolor")}} +\usage{ +reuse_scale(scale, aesthetics) +} +\arguments{ +\item{scale}{A color scale to copy from} + +\item{aesthetic}{The name of the new aesthetic or aesthetics to apply the color scale to} +} +\description{ +Make a copy of a color scale for a different aesthetic. +Example use: \code{scale_outlinecolor_hue <- reuse_scale(scale_color_hue, "outlinecolor")} +} diff --git a/man/scale_brewer.Rd b/man/scale_brewer.Rd index 073d3f0d02..27b77adf56 100644 --- a/man/scale_brewer.Rd +++ b/man/scale_brewer.Rd @@ -1,15 +1,15 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/scale-brewer.R, R/zxx.R +% Please edit documentation in R/scale-brewer.R, R/scale-color.R, R/scale-fill.R \name{scale_colour_brewer} \alias{scale_colour_brewer} -\alias{scale_fill_brewer} \alias{scale_colour_distiller} -\alias{scale_fill_distiller} \alias{scale_colour_fermenter} -\alias{scale_fill_fermenter} \alias{scale_color_brewer} \alias{scale_color_distiller} \alias{scale_color_fermenter} +\alias{scale_fill_brewer} +\alias{scale_fill_distiller} +\alias{scale_fill_fermenter} \title{Sequential, diverging and qualitative colour scales from ColorBrewer} \usage{ scale_colour_brewer( @@ -20,14 +20,6 @@ scale_colour_brewer( aesthetics = "colour" ) -scale_fill_brewer( - ..., - type = "seq", - palette = 1, - direction = 1, - aesthetics = "fill" -) - scale_colour_distiller( ..., type = "seq", @@ -40,26 +32,34 @@ scale_colour_distiller( aesthetics = "colour" ) -scale_fill_distiller( +scale_colour_fermenter( ..., type = "seq", palette = 1, direction = -1, - values = NULL, - space = "Lab", na.value = "grey50", - guide = "colourbar", + guide = "coloursteps", + aesthetics = "colour" +) + +scale_fill_brewer( + ..., + type = "seq", + palette = 1, + direction = 1, aesthetics = "fill" ) -scale_colour_fermenter( +scale_fill_distiller( ..., type = "seq", palette = 1, direction = -1, + values = NULL, + space = "Lab", na.value = "grey50", - guide = "coloursteps", - aesthetics = "colour" + guide = "colourbar", + aesthetics = "fill" ) scale_fill_fermenter( diff --git a/man/scale_colour_continuous.Rd b/man/scale_colour_continuous.Rd index c8a8a5ff45..14adbee4af 100644 --- a/man/scale_colour_continuous.Rd +++ b/man/scale_colour_continuous.Rd @@ -1,21 +1,37 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/scale-colour.R, R/zxx.R +% Please edit documentation in R/scale-colour.R, R/scale-color.R, R/scale-fill.R \name{scale_colour_continuous} \alias{scale_colour_continuous} -\alias{scale_fill_continuous} \alias{scale_colour_binned} -\alias{scale_fill_binned} \alias{scale_color_continuous} \alias{scale_color_binned} +\alias{scale_fill_binned} +\alias{scale_fill_continuous} \title{Continuous and binned colour scales} \usage{ -scale_colour_continuous(..., type = getOption("ggplot2.continuous.colour")) +scale_colour_continuous( + ..., + aesthetics = "colour", + type = getOption(glue("ggplot2.continuous.{aesthetics[1]}")) +) -scale_fill_continuous(..., type = getOption("ggplot2.continuous.fill")) +scale_colour_binned( + ..., + aesthetics = "colour", + type = getOption(glue("ggplot2.binned.{aesthetics[1]}")) +) -scale_colour_binned(..., type = getOption("ggplot2.binned.colour")) +scale_fill_binned( + ..., + aesthetics = "fill", + type = getOption(glue("ggplot2.binned.{aesthetics[1]}")) +) -scale_fill_binned(..., type = getOption("ggplot2.binned.fill")) +scale_fill_continuous( + ..., + aesthetics = "fill", + type = getOption(glue("ggplot2.continuous.{aesthetics[1]}")) +) } \arguments{ \item{...}{Additional parameters passed on to the scale type} diff --git a/man/scale_colour_discrete.Rd b/man/scale_colour_discrete.Rd index 79dd1a47db..195d18c7f2 100644 --- a/man/scale_colour_discrete.Rd +++ b/man/scale_colour_discrete.Rd @@ -1,14 +1,22 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/scale-hue.R, R/zxx.R +% Please edit documentation in R/scale-hue.R, R/scale-color.R, R/scale-fill.R \name{scale_colour_discrete} \alias{scale_colour_discrete} -\alias{scale_fill_discrete} \alias{scale_color_discrete} +\alias{scale_fill_discrete} \title{Discrete colour scales} \usage{ -scale_colour_discrete(..., type = getOption("ggplot2.discrete.colour")) +scale_colour_discrete( + ..., + aesthetics = "colour", + type = getOption(glue("ggplot2.discrete.{aesthetics[1]}")) +) -scale_fill_discrete(..., type = getOption("ggplot2.discrete.fill")) +scale_fill_discrete( + ..., + aesthetics = "fill", + type = getOption(glue("ggplot2.discrete.{aesthetics[1]}")) +) } \arguments{ \item{...}{Additional parameters passed on to the scale type,} diff --git a/man/scale_gradient.Rd b/man/scale_gradient.Rd index 35d57f2b68..a31d08834d 100644 --- a/man/scale_gradient.Rd +++ b/man/scale_gradient.Rd @@ -1,21 +1,22 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/scale-gradient.R, R/zxx.R +% Please edit documentation in R/scale-gradient.R, R/scale-colour-ordinal.R, +% R/scale-color.R, R/scale-fill.R \name{scale_colour_gradient} \alias{scale_colour_gradient} -\alias{scale_fill_gradient} \alias{scale_colour_gradient2} -\alias{scale_fill_gradient2} \alias{scale_colour_gradientn} -\alias{scale_fill_gradientn} \alias{scale_colour_datetime} -\alias{scale_color_datetime} \alias{scale_colour_date} -\alias{scale_color_date} -\alias{scale_fill_datetime} -\alias{scale_fill_date} \alias{scale_color_gradient} \alias{scale_color_gradient2} \alias{scale_color_gradientn} +\alias{scale_color_datetime} +\alias{scale_color_date} +\alias{scale_fill_datetime} +\alias{scale_fill_date} +\alias{scale_fill_gradient} +\alias{scale_fill_gradient2} +\alias{scale_fill_gradientn} \title{Gradient colour scales} \usage{ scale_colour_gradient( @@ -28,16 +29,6 @@ scale_colour_gradient( aesthetics = "colour" ) -scale_fill_gradient( - ..., - low = "#132B43", - high = "#56B1F7", - space = "Lab", - na.value = "grey50", - guide = "colourbar", - aesthetics = "fill" -) - scale_colour_gradient2( ..., low = muted("red"), @@ -50,27 +41,37 @@ scale_colour_gradient2( aesthetics = "colour" ) -scale_fill_gradient2( +scale_colour_gradientn( ..., - low = muted("red"), - mid = "white", - high = muted("blue"), - midpoint = 0, + colours, + values = NULL, + space = "Lab", + na.value = "grey50", + guide = "colourbar", + aesthetics = "colour", + colors +) + +scale_fill_gradient( + ..., + low = "#132B43", + high = "#56B1F7", space = "Lab", na.value = "grey50", guide = "colourbar", aesthetics = "fill" ) -scale_colour_gradientn( +scale_fill_gradient2( ..., - colours, - values = NULL, + low = muted("red"), + mid = "white", + high = muted("blue"), + midpoint = 0, space = "Lab", na.value = "grey50", guide = "colourbar", - aesthetics = "colour", - colors + aesthetics = "fill" ) scale_fill_gradientn( diff --git a/man/scale_grey.Rd b/man/scale_grey.Rd index b25989858c..9e88cc3c74 100644 --- a/man/scale_grey.Rd +++ b/man/scale_grey.Rd @@ -1,9 +1,9 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/scale-grey.R, R/zxx.R +% Please edit documentation in R/scale-grey.R, R/scale-color.R, R/scale-fill.R \name{scale_colour_grey} \alias{scale_colour_grey} -\alias{scale_fill_grey} \alias{scale_color_grey} +\alias{scale_fill_grey} \title{Sequential grey colour scales} \usage{ scale_colour_grey( diff --git a/man/scale_hue.Rd b/man/scale_hue.Rd index 73c1fe0ade..009185bc17 100644 --- a/man/scale_hue.Rd +++ b/man/scale_hue.Rd @@ -1,9 +1,9 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/scale-hue.R, R/zxx.R +% Please edit documentation in R/scale-hue.R, R/scale-color.R, R/scale-fill.R \name{scale_colour_hue} \alias{scale_colour_hue} -\alias{scale_fill_hue} \alias{scale_color_hue} +\alias{scale_fill_hue} \title{Evenly spaced colours for discrete data} \usage{ scale_colour_hue( diff --git a/man/scale_identity.Rd b/man/scale_identity.Rd index 5ee1c31dfb..d989d9f649 100644 --- a/man/scale_identity.Rd +++ b/man/scale_identity.Rd @@ -1,8 +1,8 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/scale-identity.R, R/zxx.R +% Please edit documentation in R/scale-identity.R, R/scale-color.R, +% R/scale-fill.R \name{scale_identity} \alias{scale_colour_identity} -\alias{scale_fill_identity} \alias{scale_shape_identity} \alias{scale_linetype_identity} \alias{scale_linewidth_identity} @@ -11,12 +11,11 @@ \alias{scale_discrete_identity} \alias{scale_continuous_identity} \alias{scale_color_identity} +\alias{scale_fill_identity} \title{Use values without scaling} \usage{ scale_colour_identity(..., guide = "none", aesthetics = "colour") -scale_fill_identity(..., guide = "none", aesthetics = "fill") - scale_shape_identity(..., guide = "none") scale_linetype_identity(..., guide = "none") @@ -30,6 +29,8 @@ scale_size_identity(..., guide = "none") scale_discrete_identity(aesthetics, ..., guide = "none") scale_continuous_identity(aesthetics, ..., guide = "none") + +scale_fill_identity(..., guide = "none", aesthetics = "fill") } \arguments{ \item{...}{Other arguments passed on to \code{\link[=discrete_scale]{discrete_scale()}} or diff --git a/man/scale_manual.Rd b/man/scale_manual.Rd index 7a3f7402cf..eefcf49076 100644 --- a/man/scale_manual.Rd +++ b/man/scale_manual.Rd @@ -1,8 +1,7 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/scale-manual.R, R/zxx.R +% Please edit documentation in R/scale-manual.R, R/scale-color.R, R/scale-fill.R \name{scale_manual} \alias{scale_colour_manual} -\alias{scale_fill_manual} \alias{scale_size_manual} \alias{scale_shape_manual} \alias{scale_linetype_manual} @@ -10,6 +9,7 @@ \alias{scale_alpha_manual} \alias{scale_discrete_manual} \alias{scale_color_manual} +\alias{scale_fill_manual} \title{Create your own discrete scale} \usage{ scale_colour_manual( @@ -20,14 +20,6 @@ scale_colour_manual( na.value = "grey50" ) -scale_fill_manual( - ..., - values, - aesthetics = "fill", - breaks = waiver(), - na.value = "grey50" -) - scale_size_manual(..., values, breaks = waiver(), na.value = NA) scale_shape_manual(..., values, breaks = waiver(), na.value = NA) @@ -39,6 +31,14 @@ scale_linewidth_manual(..., values, breaks = waiver(), na.value = NA) scale_alpha_manual(..., values, breaks = waiver(), na.value = NA) scale_discrete_manual(aesthetics, ..., values, breaks = waiver()) + +scale_fill_manual( + ..., + values, + aesthetics = "fill", + breaks = waiver(), + na.value = "grey50" +) } \arguments{ \item{...}{ diff --git a/man/scale_steps.Rd b/man/scale_steps.Rd index 4ce18b6839..dbba0d450d 100644 --- a/man/scale_steps.Rd +++ b/man/scale_steps.Rd @@ -1,15 +1,15 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/scale-steps.R, R/zxx.R +% Please edit documentation in R/scale-steps.R, R/scale-color.R, R/scale-fill.R \name{scale_colour_steps} \alias{scale_colour_steps} \alias{scale_colour_steps2} \alias{scale_colour_stepsn} -\alias{scale_fill_steps} -\alias{scale_fill_steps2} -\alias{scale_fill_stepsn} \alias{scale_color_steps} \alias{scale_color_steps2} \alias{scale_color_stepsn} +\alias{scale_fill_steps} +\alias{scale_fill_steps2} +\alias{scale_fill_stepsn} \title{Binned gradient colour scales} \usage{ scale_colour_steps( diff --git a/man/scale_viridis.Rd b/man/scale_viridis.Rd index 4550146e7e..4444a789ad 100644 --- a/man/scale_viridis.Rd +++ b/man/scale_viridis.Rd @@ -1,18 +1,19 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/scale-viridis.R, R/zxx.R +% Please edit documentation in R/scale-viridis.R, R/scale-colour-ordinal.R, +% R/scale-color.R, R/scale-fill.R \name{scale_colour_viridis_d} \alias{scale_colour_viridis_d} -\alias{scale_fill_viridis_d} \alias{scale_colour_viridis_c} -\alias{scale_fill_viridis_c} \alias{scale_colour_viridis_b} -\alias{scale_fill_viridis_b} \alias{scale_colour_ordinal} -\alias{scale_color_ordinal} -\alias{scale_fill_ordinal} \alias{scale_color_viridis_d} \alias{scale_color_viridis_c} \alias{scale_color_viridis_b} +\alias{scale_color_ordinal} +\alias{scale_fill_ordinal} +\alias{scale_fill_viridis_b} +\alias{scale_fill_viridis_c} +\alias{scale_fill_viridis_d} \title{Viridis colour scales from viridisLite} \usage{ scale_colour_viridis_d( @@ -25,17 +26,21 @@ scale_colour_viridis_d( aesthetics = "colour" ) -scale_fill_viridis_d( +scale_colour_viridis_c( ..., alpha = 1, begin = 0, end = 1, direction = 1, option = "D", - aesthetics = "fill" + values = NULL, + space = "Lab", + na.value = "grey50", + guide = "colourbar", + aesthetics = "colour" ) -scale_colour_viridis_c( +scale_colour_viridis_b( ..., alpha = 1, begin = 0, @@ -45,11 +50,11 @@ scale_colour_viridis_c( values = NULL, space = "Lab", na.value = "grey50", - guide = "colourbar", + guide = "coloursteps", aesthetics = "colour" ) -scale_fill_viridis_c( +scale_fill_viridis_b( ..., alpha = 1, begin = 0, @@ -59,11 +64,11 @@ scale_fill_viridis_c( values = NULL, space = "Lab", na.value = "grey50", - guide = "colourbar", + guide = "coloursteps", aesthetics = "fill" ) -scale_colour_viridis_b( +scale_fill_viridis_c( ..., alpha = 1, begin = 0, @@ -73,21 +78,17 @@ scale_colour_viridis_b( values = NULL, space = "Lab", na.value = "grey50", - guide = "coloursteps", - aesthetics = "colour" + guide = "colourbar", + aesthetics = "fill" ) -scale_fill_viridis_b( +scale_fill_viridis_d( ..., alpha = 1, begin = 0, end = 1, direction = 1, option = "D", - values = NULL, - space = "Lab", - na.value = "grey50", - guide = "coloursteps", aesthetics = "fill" ) }