Transformations
- Several scale transformation functions that work on the x- or y-axis.
- All of these transformations do not affect the data, they just modify the axes.
- Every continuous scale takes a
transform
argument allowing for using transformations:
You can construct your own transform by using
scales::new_transform
The following table lists some of the more common variants:
Name | Transformer | Function f(x) | Inverse f−1(x) |
---|---|---|---|
"asn" |
scales::transform_asn |
tanh−1(x) | tanh(y) |
"exp" |
scales::transform_exp () |
ex | log(y) |
"identity" |
scales::transform_identity() |
x | y |
"log" |
scales::transform_log() |
log(x) | ey |
"log10" |
scales::transform_log10() |
log10(x) | 10y |
"log2" |
scales::transform_log2() |
log2(x) | 2y |
"logit" |
scales::transform_logit() |
log(x1−x) | 11+e(y) |
"probit" |
scales::transform_probit() |
Φ(x) | Φ−1(y) |
"reciprocal" |
scales::transform_reciprocal() |
x−1 | y−1 |
"reverse" |
scales::transform_reverse() |
−x | −y |
"sqrt" |
scales::scale_x_sqrt() |
x1/2 | y2 |
- Let’s see an example:
- Remember you can transform the data manually first and opt not to do the transformation on the axes.
- The appearance of the geom will be the same, but the tick labels will be different.
- If you transform the data, the axes will be labelled in the transformed space.
- If you use a transformed scale, the axes will be labelled in the original data space.
- Regardless of which method you use, the transformation occurs before any statistical summaries. To transform after statistical computation use
coord_trans()
.