Creates a continuous log scale, where input values are transformed with log_trans(base) before calculating the output.
Log scales can be useful in transforming positively skewed data.
Usage
scale_color_log(
col,
palette = scales::viridis_pal(),
na_color = "#000000",
base = 10,
limits = NULL,
breaks = NULL,
n_ticks = NULL,
tick_format = format_number,
col_label = "{.col}",
legend = TRUE
)
scale_log(
col,
range = 0:1,
na_value = 0,
base = 10,
limits = NULL,
breaks = NULL,
col_label = "{.col}",
legend = TRUE
)Arguments
- col
<
name|string> The name of the column containing data to be scaled. Must be a valid input torlang::ensym(); either a named column (non-standard evaluation), a string. Supports tidy-eval.- palette
<
color|function> The colour palette of the colour scale. Must be a:vector of RGBA hex colours,
a palette generator function, taking a length parameter, or
a palette ramp created from
scales::colour_ramp()
A
scales::colour_ramp()interpolator is created from the input palette.- na_color
<
color> The colour value forNAinput values.- base
<
number> The log base. The log base must be a strictly positive value != 1.- limits
<
c(min, max)> The limits of the scale's input. IfNULL, limits are computed from layer data. Values outside the range of limits are clamped.- breaks
<
numeric|function> The breaks of the scale, allowing to define a piecewise scale. The scalepaletteor numericrangeare linearly interpolated (by length) and mapped ontobreaks. Breaks outside thelimitsof the scale are discarded.If not
NULL, breaks must be either:a numeric vector
a breaks function, taking a numeric vector argument (e.g.
breaks_linear())
Defaults to
breaks_trans()wheretransis the scale's transformer.- n_ticks
<
number> The number of ticks to display on the legend. Must be >= 2. The legend size will grow and shrink depending on this value.- tick_format
<
function> A label function taking a vector of ticks returning formatted ticks.- col_label
<
string|function> A template string or a label function for customising the column name in the legend.if
col_labelis a string,{.col}may be used to represent thecolnameif
col_labelis a function, the function must take a single argument: thecolname
- legend
<
boolean> Indicate whether the legend should be displayed for this scale.- range
<
numeric> The output range of the numeric scale. Must be length >= 2. Astats::approxfun()interpolator is created from the input range.- na_value
<
number> The output value forNAinput values.
See also
Other scales:
rescale_center(),
rescale_diverge(),
scale_category(),
scale_identity(),
scale_linear(),
scale_power(),
scale_quantile(),
scale_quantize(),
scale_symlog(),
scale_threshold()