Draw a ggplot2 layer using a grob or a function.
Arguments
- ...
Arguments passed on to
ggplot2::discrete_scale
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.labels
One of:
NULL
for 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:
NULL
to use the default scale valuesA character vector that defines possible values of the scale and their order
A function that accepts the existing (automatic) values and returns new ones. Also accepts rlang lambda function notation.
na.translate
Unlike continuous scales, discrete scales can easily show missing values, and do so by default. If you want to remove missing values from a discrete scale, specify
na.translate = FALSE
.drop
Should unused factor levels be omitted from the scale? The default,
TRUE
, uses the levels that appear in the data;FALSE
includes the levels in the factor. Please note that to display every level in a legend, the layer should useshow.legend = TRUE
.guide
A function used to create a guide or its name. See
guides()
for more information.call
The
call
used to construct the scale for reporting messages.super
The super class to use for the constructed scale
- values
A list of functions (including purrr-like lambda syntax) that define how each cell's grob (graphical object) should be drawn.
- aesthetics
Character string or vector of character strings listing the name(s) of the aesthetic(s) that this scale works with. This can be useful, for example, to apply colour settings to the
colour
andfill
aesthetics at the same time, viaaesthetics = c("colour", "fill")
.- breaks
One of:
NULL
for no breakswaiver()
for the default breaks (the scale limits)A character vector of breaks
A function that takes the limits as input and returns breaks as output
- na.value
The aesthetic value to use for missing (
NA
) values
Details
If you want to combine the functionality of multiple geoms, it can
typically be achieved by preparing the data for each geom inside the
draw_*()
call and sending it off to the different geoms, collecting the
output in a grid::gList
(a list of grobs) for draw_group()
or a
grid::gTree
(a grob containing multiple child grobs) for
draw_panel()
.