Continuous scale for the pictogram value aesthetic
Source:R/scale-value.R
scale_value_continuous.Rdscale_value_continuous() registers value (as mapped in
geom_pictogram()) as a real trained aesthetic, purely so it can carry a
default guide (see guide_pictogram()). It never rescales value
itself: symbol_value slot counts need the real data value, so the
palette is the identity function.
Arguments
- 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. IfNULL, the legend title will be omitted.- breaks
One of:
NULLfor no breakswaiver()for the default breaks computed by the transformation objectA numeric vector of positions
A function that takes the limits as input and returns breaks as output (e.g., a function returned by
scales::extended_breaks()). Note that for position scales, limits are provided after scale expansion. Also accepts rlang lambda function notation.
- labels
One of the options below. Please note that when
labelsis a vector, it is highly recommended to also set thebreaksargument as a vector to protect against unintended mismatches.NULLfor no labelswaiver()for the default labels computed by the transformation objectA character vector giving labels (must be same length as
breaks)An expression vector (must be the same length as breaks). See ?plotmath for details.
A function that takes the breaks as input and returns labels as output. Also accepts rlang lambda function notation.
- limits
One of:
NULLto use the default scale rangeA numeric vector of length two providing limits of the scale. Use
NAto refer to the existing minimum or maximumA function that accepts the existing (automatic) limits and returns new limits. Also accepts rlang lambda function notation. Note that setting limits on positional scales will remove data outside of the limits. If the purpose is to zoom, use the limit argument in the coordinate system (see
coord_cartesian()).
- guide
The value legend's guide; defaults to
guide_pictogram(). Set to"none"(or passshow.legend = FALSEtogeom_pictogram()) to hide it.- ...
Arguments passed on to
continuous_scaleminor_breaksOne of:
NULLfor no minor breakswaiver()for the default breaks (none for discrete, one minor break between each major break for continuous)A numeric vector of positions
A function that given the limits returns a vector of minor breaks. Also accepts rlang lambda function notation. When the function has two arguments, it will be given the limits and major break positions.
oobOne of:
Function that handles limits outside of the scale limits (out of bounds). Also accepts rlang lambda function notation.
The default (
scales::censor()) replaces out of bounds values withNA.scales::squish()for squishing out of bounds values into range.scales::squish_infinite()for squishing infinite values into range.
na.valueMissing values will be replaced with this value.
callThe
callused to construct the scale for reporting messages.superThe super class to use for the constructed scale
Details
Picked up automatically for aes(value = ...), so most plots never need
to call it directly. Exported for overriding guide or setting explicit
breaks.
Examples
library(ggplot2)
# bundled placeholder shapes; a real pack (e.g. icons::fontawesome) works the same
shapes <- icons::icon_set(system.file("icons", package = "ggicons"))
# applied automatically; shown explicitly here just to relabel the legend
ggplot(NULL, aes(x = "Proportion", value = 37)) +
geom_pictogram(icon = shapes$square, n = 100, nrow = 10) +
scale_value_continuous(name = "%")
#> Error in geom_pictogram(icon = shapes$square, n = 100, nrow = 10): Problem while converting geom to grob.
#> ℹ Error occurred in the 1st layer.
#> Caused by error in `loadNamespace()`:
#> ! there is no package called ‘grImport2’