boxcox_trans ¶
boxcox_trans(
p: Number, offset: Number = 0
) -> BoxCoxTransform
Box-Cox power transform, as a value for trans.
Maps x to ((x + offset) ** p - 1) / p, and to log(x + offset) when
p is 0. Follows scales::boxcox_trans in ggplot2.
Parameters:
-
p(int or float) –The power.
-
offset(int or float, default:0) –Added to the data before the power.
Returns:
-
BoxCoxTransform–The transform name, to pass as
trans.
Raises:
-
SpecError–If
poroffsetis not a finite number.
Examples:
>>> from ggrust import *
>>> data = {"income": [12, 30, 45, 80, 240], "spending": [10, 22, 30, 41, 90]}
>>> plot = ggplot(data, aes("income", "spending")) + geom_point()
>>> plot = plot + scale_x_continuous(trans=boxcox_trans(0.5))