safeLog Scale (GPL)
Syntax
safeLog(dim(<numeric>), <function>)
or
safeLog(aesthetic(aesthetic.<aesthetic type>), <function>)
<numeric>. A numeric value indicating the dimension to which the scale applies. See the topic dim Function (GPL) for more information.
<function>. One or more valid functions. These are optional.
<aesthetic type>. An aesthetic type indicating the
aesthetic to which the scale applies. This is an aesthetic created
as the result of an aesthetic function (such as size
)
in the ELEMENT
statement.
Description
Creates a "safe" logarithmic-transformed scale. Unlike a regular log scale, the safe log scale uses a modified function to handle 0 and negative values. If a base is not explicitly specified, the default is base 10.
Formula for Safe Log Transformation
The safe log formula is:
sign(x) * log(1 + abs(x))
So if you assume that the axis value is –99, the result of the transformation is:
sign(-99) * log(1 + abs(-99)) = -1 * log(1 + 99) = -1 * 2 = -2
Example
SCALE: safeLog(dim(2), base(2))