scale_threshold | R Documentation |
Creates a discrete threshold scale. Threshold scales slice palette
or range
into
length(breaks) + 1
bins, with each break defining the threshold between 2 bins.
Threshold scales can be used to create any discrete scale, using either manual breaks or generated breaks via a transform (e.g. breaks_power(n = 6, exponent = 0.5) for a discrete sqrt scale).
scale_color_threshold(
col,
palette = scales::viridis_pal(),
na_color = "#000000",
limits = NULL,
breaks = 0.5,
tick_format = format_number,
col_label = "{.col}",
legend = TRUE
)
scale_threshold(
col,
range = 0:1,
na_value = 0,
limits = NULL,
breaks = 0.5,
tick_format = format_number,
col_label = "{.col}",
legend = TRUE
)
col |
< |
palette |
<
A |
na_color |
< |
limits |
< |
breaks |
< If not
Breaks must be in increasing order. Each break will be present on the legend for colour scales. |
tick_format |
< |
col_label |
<
|
legend |
< |
range |
< |
na_value |
< |
Threshold scales don't require limits, but breaks_trans()
does.
Other scales:
rescale_center()
,
rescale_diverge()
,
scale_category()
,
scale_identity()
,
scale_linear()
,
scale_log()
,
scale_power()
,
scale_quantile()
,
scale_quantize()
,
scale_symlog()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.