Description Super class Methods
Most useful scales will inherit from ScaleContinuous or ScaleDiscrete, both of which use the scales package to create meaningful mappings between user data and aesthetics with useful breaks and labels.
ggr6::Scale
-> ScaleSimple
new()
ScaleSimple$new(aesthetics = character(0))
is_empty()
ScaleSimple$is_empty()
Returns TRUE
if the scale has $limits()
(or can calculate them).
transform()
ScaleSimple$transform(x)
untransform()
ScaleSimple$untransform(x)
transform_tbl()
ScaleSimple$transform_tbl(data)
untransform_tbl()
ScaleSimple$untransform_tbl(data)
train()
ScaleSimple$train(x)
train_tbl()
ScaleSimple$train_tbl(data_trans)
reset()
ScaleSimple$reset()
map_tbl()
ScaleSimple$map_tbl(data_trans)
breaks()
ScaleSimple$breaks()
breaks_minor()
ScaleSimple$breaks_minor()
Calculates and returns minor breaks in transformed data space. This can
be a function of the $breaks()
, $limits()
, and number of intervals
between breaks (usually 2). Minor breaks usually don't make sense for
discrete scales.
labels()
ScaleSimple$labels()
Calculates and returns the labels associated with the $breaks()
. This
can be a function of the $breaks()
, and by default the $format()
method
of the transform is used.
limits()
ScaleSimple$limits()
Calculates and returns the limits. This can be a funnction of the
$trained_range()
, and defaults to returning the $trained_range()
.
Continuous limits are always a numeric vector of length 2; discrete limits
are usually a character vector containing possible values.
trained_range()
ScaleSimple$trained_range()
The range of the values in transformed data space that were observed
for this scale's aesthetics. Contiuous ranges are always NULL
(when no
values were observed) or a numeric vector of length 2; discrete ranges
are usually a character vector of values that were observed in the data.
set_breaks()
ScaleSimple$set_breaks(breaks)
Set the breaks for this scale. Can be a vector of breaks in user data space
or a function of the $limits()
.
set_breaks_minor()
ScaleSimple$set_breaks_minor(breaks_minor)
Set the minor breaks for this scale. Can be a vector of breaks in user data space
or a function of the $breaks()
, $limits()
, and the number 2.
set_labels()
ScaleSimple$set_labels(labels)
Set the labels for this scale. Can be a vector of labels or a function of
the $breaks()
.
set_limits()
ScaleSimple$set_limits(limits)
Set the limits for this scale. Can be a function of the $trained_range()
or
a vector (length 2 numeric for continuous scales or a character vector for
discrete scales).
@details
Set the out-of-bounds function for this scale. The out-of-bounds function
is a function of a vector and the $limits()
; useful oob functions include
oob_keep()
(which does nothing; the default),
scales::censor()
(which sets values outside the limits to NA
) and
scales::squish()
(which sets values outside the limits to the outermost values),
and censor_discrete()
(which works like scales::censor()
but works for
discrete scales).
set_oob()
ScaleSimple$set_oob(oob)
set_range()
ScaleSimple$set_range(range)
Set the range class for this scale. This must be a subclass of scales::Range.
set_rescaler()
ScaleSimple$set_rescaler(rescaler)
Set the rescaler function for this scale. Rescaled values (between 0 and 1)
are often useful as inputs to continuous palletes. This function should take
a keyword argument from
, which is the scale $limits()
. The most useful
values for rescaler
are rescale_none()
(the default) and scales::rescale()
.
set_trans()
ScaleSimple$set_trans(trans)
Set the transform for this scale. See scales::trans_new()
for a list
of transforms for continuous scales. For discrete scales, the default
value of discrete_identity_trans()
is probably the only value that makes
sense.
set_na_value()
ScaleSimple$set_na_value(na_value)
Set the output (mapped data space) value that will represent NA
values
for this scale.
set_limits_empty()
ScaleSimple$set_limits_empty(limits_empty)
Set the limits to return (in transformed data space) when $is_empty()
returns TRUE
.
clone()
The objects of this class are cloneable with this method.
ScaleSimple$clone(deep = FALSE)
deep
Whether to make a deep clone.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.