1
1
# ' Continuous and binned colour scales
2
2
# '
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()].
7
29
# '
8
30
# ' @param ... Additional parameters passed on to the scale type
9
31
# ' @param type One of the following:
13
35
# ' @seealso [scale_colour_gradient()], [scale_colour_viridis_c()],
14
36
# ' [scale_colour_steps()], [scale_colour_viridis_b()], [scale_fill_gradient()],
15
37
# ' [scale_fill_viridis_c()], [scale_fill_steps()], and [scale_fill_viridis_b()]
16
- # ' @export
38
+ # ' @family colour scales
17
39
# ' @rdname scale_colour_continuous
18
40
# ' @section Color Blindness:
19
41
# ' Many color palettes derived from RGB combinations (like the "rainbow" color
40
62
# ' # The above are equivalent to
41
63
# ' v + scale_fill_gradient()
42
64
# ' 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
43
76
scale_colour_continuous <- function (... ,
44
77
type = getOption(" ggplot2.continuous.colour" , default = " gradient" )) {
45
78
if (is.function(type )) {
@@ -70,7 +103,6 @@ scale_fill_continuous <- function(...,
70
103
71
104
# ' @export
72
105
# ' @rdname scale_colour_continuous
73
- # ' @usage NULL
74
106
scale_colour_binned <- function (... ,
75
107
type = getOption(" ggplot2.binned.colour" , default = getOption(" ggplot2.continuous.colour" , default = " gradient" ))) {
76
108
if (is.function(type )) {
@@ -86,7 +118,6 @@ scale_colour_binned <- function(...,
86
118
87
119
# ' @export
88
120
# ' @rdname scale_colour_continuous
89
- # ' @usage NULL
90
121
scale_fill_binned <- function (... ,
91
122
type = getOption(" ggplot2.binned.fill" , default = getOption(" ggplot2.continuous.fill" , default = " gradient" ))) {
92
123
if (is.function(type )) {
0 commit comments