safePower Scale (GPL)

Syntax

safePower(dim(<numeric>), <function>)

or

safePower(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" power-transformed scale. Unlike a regular power scale, the safe power scale uses a modified function to handle negative values. If an exponent is not explicitly specified, the default is 0.5.

Formulas for Safe Power Transformation

When the exponent is a positive number, the safe power formulas are:

If (x>=0):
pow(1+x, exponent)-1
If (x<0):
1-pow(1-x, exponent)

When the exponent is a negative number, the safe power formulas are:

If (x>=0):
1-pow(1+x, exponent)
If (x<0):
pow(1-x, exponent)-1

So, if you assume the axis value is –99 and the exponent is 0.5, the result of the transformation is:

1 - pow(1 - (-99), 0.5) = 1 - pow(100, 0.5) = 1 - 10 = -9

So, if you assume the axis value is –99 and the exponent is –2, the result of the transformation is:

pow(1 - (-99), -2) - 1 = pow(100, -2) - 1 = 0.0001 - 1 = -0.999

Example

Figure 1. Example: Specifying the scale and an exponent
SCALE: safePower(dim(2), exponent(10))