11# ' Continuous and binned colour scales
22# '
3- # ' Colour scales for continuous data default to the values of the
4- # ' `ggplot2.continuous.colour` and `ggplot2.continuous.fill` options. These
5- # ' [options()] default to `"gradient"` (i.e., [scale_colour_gradient()] and
6- # ' [scale_fill_gradient()])
3+ # ' The scales `scale_colour_continuous()` and `scale_fill_continuous()` are
4+ # ' the default colour scales ggplot2 uses when continuous data values are
5+ # ' mapped onto the `colour` or `fill` aesthetics, respectively. The scales
6+ # ' `scale_colour_binned()` and `scale_fill_binned()` are equivalent scale
7+ # ' functions that assign discrete color bins to the continuous values
8+ # ' instead of using a continuous color spectrum.
9+ # '
10+ # ' All these colour scales use the [options()] mechanism to determine
11+ # ' default settings. Continuous colour scales default to the values of the
12+ # ' `ggplot2.continuous.colour` and `ggplot2.continuous.fill` options, and
13+ # ' binned colour scales default to the values of the `ggplot2.binned.colour`
14+ # ' and `ggplot2.binned.fill` options. These option values default to
15+ # ' `"gradient"`, which means that the scale functions actually used are
16+ # ' [scale_colour_gradient()]/[scale_fill_gradient()] for continuous scales and
17+ # ' [scale_colour_steps()]/[scale_fill_steps()] for binned scales.
18+ # ' Alternative option values are `"viridis"` or a different scale function.
19+ # ' See description of the `type` argument for details.
20+ # '
21+ # ' Note that the binned colour scales will use the settings of
22+ # ' `ggplot2.continuous.colour` and `ggplot2.continuous.fill` as fallback,
23+ # ' respectively, if `ggplot2.binned.colour` or `ggplot2.binned.fill` are
24+ # ' not set.
25+ # '
26+ # ' These scale functions are meant to provide simple defaults. If
27+ # ' you want to manually set the colors of a scale, consider using
28+ # ' [scale_colour_gradient()] or [scale_colour_steps()].
729# '
830# ' @param ... Additional parameters passed on to the scale type
931# ' @param type One of the following:
1335# ' @seealso [scale_colour_gradient()], [scale_colour_viridis_c()],
1436# ' [scale_colour_steps()], [scale_colour_viridis_b()], [scale_fill_gradient()],
1537# ' [scale_fill_viridis_c()], [scale_fill_steps()], and [scale_fill_viridis_b()]
16- # ' @export
38+ # ' @family colour scales
1739# ' @rdname scale_colour_continuous
1840# ' @section Color Blindness:
1941# ' Many color palettes derived from RGB combinations (like the "rainbow" color
4062# ' # The above are equivalent to
4163# ' v + scale_fill_gradient()
4264# ' v + scale_fill_viridis_c()
65+ # '
66+ # ' # To make a binned version of this plot
67+ # ' v + scale_fill_binned(type = "viridis")
68+ # '
69+ # ' # Set a different default scale using the options
70+ # ' # mechanism
71+ # ' tmp <- getOption("ggplot2.continuous.fill") # store current setting
72+ # ' options(ggplot2.continuous.fill = scale_fill_distiller)
73+ # ' v
74+ # ' options(ggplot2.continuous.fill = tmp) # restore previous setting
75+ # ' @export
4376scale_colour_continuous <- function (... ,
4477 type = getOption(" ggplot2.continuous.colour" , default = " gradient" )) {
4578 if (is.function(type )) {
@@ -70,7 +103,6 @@ scale_fill_continuous <- function(...,
70103
71104# ' @export
72105# ' @rdname scale_colour_continuous
73- # ' @usage NULL
74106scale_colour_binned <- function (... ,
75107 type = getOption(" ggplot2.binned.colour" , default = getOption(" ggplot2.continuous.colour" , default = " gradient" ))) {
76108 if (is.function(type )) {
@@ -86,7 +118,6 @@ scale_colour_binned <- function(...,
86118
87119# ' @export
88120# ' @rdname scale_colour_continuous
89- # ' @usage NULL
90121scale_fill_binned <- function (... ,
91122 type = getOption(" ggplot2.binned.fill" , default = getOption(" ggplot2.continuous.fill" , default = " gradient" ))) {
92123 if (is.function(type )) {
0 commit comments