scales
scales copied to clipboard
Add inverse hyperbolic sine transformation
Sometimes it's nice to have a 'log'-transformation that also works for negative values to have points more evenly spread-out:
ihs <- function(x){log(x+sqrt(x^2+1))}
ihs_trans <- scales::trans_new(name="ihs",transform=ihs, inverse=sinh)
set.seed(1)
data <- tibble(
x=runif(10^4),
y=rnorm(10^4)
)
data %>%
ggplot(aes(x,y)) +
geom_point(alpha=.7) +
ggtitle("regular")
data %>%
ggplot(aes(x,y)) +
geom_point(alpha=.7) +
scale_y_continuous(trans=ihs_trans) +
ggtitle("ihs")
Sure, do you want to do a PR?
Fixed by #360