| set_scale | R Documentation |
Define a scale for an aesthetic channel
set_scale(
spec,
aesthetic,
type = "auto",
domain = NULL,
range = NULL,
nice = TRUE,
zero = FALSE,
reverse = FALSE,
label = NULL,
format = NULL,
base = NULL
)
spec |
A glyph_spec |
aesthetic |
Which channel: "x", "y", "color", "size", "shape", "alpha" |
type |
Scale type: "linear", "log", "sqrt", "time", "ordinal", "band", "quantize", "threshold" |
domain |
Explicit domain (data range). NULL for auto. A domain set here is used as given, so it is also how to start the value axis of a bar, area or histogram somewhere other than zero. |
range |
Explicit output range. For color: a palette name or vector. |
nice |
Round domain to nice values (TRUE/FALSE) |
zero |
Force zero in domain (TRUE/FALSE). Bar, area and histogram
marks always include zero on their value axis unless |
reverse |
Reverse the scale |
label |
Axis/legend label (NULL for auto from column name) |
format |
Format string for tick labels (e.g. "$.2f", "%b %Y") |
base |
Log base, used when |
Modified glyph_spec
glyph(mtcars, x = wt, y = mpg) |>
mark_point(color = cyl) |>
set_scale("y", "linear", zero = TRUE, label = "Miles per gallon") |>
set_scale("color", "ordinal", range = "Set2")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.