Constructs a chromatic scale. A chromatic scale can take several values for
the same observations and places these as coordinates in a colour space.
chromatic_scale(
aesthetics,
scale_name,
palette,
name = waiver(),
breaks = waiver(),
n.breaks = NULL,
labels = waiver(),
limits = NULL,
rescaler = rescale,
oob = oob_censor,
expand = waiver(),
na.value = "grey50",
trans = "identity",
guide = "chromatic",
prototype = NULL,
channel_limits = NULL,
super = ScaleChromatic
)
Arguments
aesthetics |
The names of the aesthetics that this scale works with. |
scale_name |
The name of the scale that should be used for error messages
associated with this scale. |
palette |
A palette function that when called with a colour_spec
vector should return a vector of colours. |
name |
The name of the scale. Used as the axis or legend title. If
waiver() , the default, the name of the scale is taken from the first
mapping used for that aesthetic. If NULL , the legend title will be
omitted. |
breaks |
One of
NULL for no breaks.
waiver() for the default breaks computed by the
transformation object.
A colour_spec vector. For continuous channels, must be a numeric
channel. For discrete channels, a character channel. Channels can be padded
with NA s if the desired breaks are of unequal length.
A function that uses the limits as input and returns breaks. Note
that this is used for both continuous and discrete channels.
A named list with the names of channels with (1) a character
or numeric vector giving the breaks for that channel or (2) a function to
be applied to the limits of that channel or (3) NULL for no breaks in
that channel. Channels whose names are absent in the list 's names are
treated with the waiver() option above.
|
n.breaks |
An integer guiding the number of major breaks. The algorithm
may choose a slightly different number to ensure nice break labels. Will
only have an effect if breaks = waiver() . Use NULL to use the default
number of breaks given by the transformation. |
labels |
One of
NULL for no labels.
waiver() for the default labels. In case of continuous channels,
these are passed through the format function of the
transformation object.
A colour_spec vector with character vectors in the channels. The
channels can be padded with NA s to match the length of channels with the
most breaks.
A function that uses the breaks as input and returns labels. Note
that this is used for both continuous and discrete channels.
A named list with the names of channels with (1) a character
vector giving the labels for that channel or (2) a function to be applied to
the breaks of that channel or (3) NULL for no labels in that channel.
Channels whose names are absent in the list 's names are treated with the
waiver() option above.
|
limits |
One of
NULL to use the default scale range.
A colour_spec vector. For continuous channels, must be a length 2
vector giving the minimum and maximum. For discrete channels, the relevant
channel should define possible values. For mixed usage, the continuous
limits can be padded with NA s.
A function that accepts the existing (automatic) limits and returns
new limits. Note that this is used for both continuous and discrete
channels.
A named list with names of channels with (1) a vector defining
the limits or (2) a function to be applied to the natural limits. Channels
whose names are absent in the list 's names are treated with the NULL
option above.
|
rescaler |
A function used to scale the input values to the
range [0, 1]. This is always scales::rescale() , except for
diverging and n colour gradients (i.e., scale_colour_gradient2() ,
scale_colour_gradientn() ). The rescaler is ignored by position
scales, which always use scales::rescale() . |
oob |
One of: |
expand |
For position scales, a vector of range expansion constants used to add some
padding around the data to ensure that they are placed some distance
away from the axes. Use the convenience function expansion()
to generate the values for the expand argument. The defaults are to
expand the scale by 5% on each side for continuous variables, and by
0.6 units on each side for discrete variables. |
na.value |
Missing values will be replaced with this value. |
trans |
For continuous scales, the name of a transformation object
or the object itself. Built-in transformations include "asn", "atanh",
"boxcox", "date", "exp", "hms", "identity", "log", "log10", "log1p", "log2",
"logit", "modulus", "probability", "probit", "pseudo_log", "reciprocal",
"reverse", "sqrt" and "time".
A transformation object bundles together a transform, its inverse,
and methods for generating breaks and labels. Transformation objects
are defined in the scales package, and are called <name>_trans (e.g.,
scales::boxcox_trans() ). You can create your own
transformation with scales::trans_new() . |
guide |
A function used to create a guide or its name. See
guides() for more information. |
prototype |
A function that serves as constructor for the specific
colour_spec class. |
channel_limits |
One of:
A colour_spec vector of length 2 containing numeric channels that
indicating the limits for each channel between 0-1.
A named list with channel names and length 1 or 2 numeric vectors
that indicate the limits for that channel between 0-1.
|
super |
The super class to use for the constructed scale |
Value
A ScaleChromatic
ggproto object.
See also
The scale_chromatic
page.
Examples
# See the documentation for the scales themselves.
NULL
#> NULL