| scale_ll4 | R Documentation |
This function generates a ggplot2 continuous scale that applies the ll4
transformation (and its inverse ll4_inv) to an axis. This is useful for
visualizing data spanning multiple orders of magnitude while handling zeros.
scale_ll4(..., lambda = 4)
... |
Arguments passed on to |
lambda |
A positive numeric scalar, the lambda parameter for the |
A ggplot2 scale object.
ll4, ll4_inv, trans_new
if (require(ggplot2) && require(scales)) {
set.seed(123)
df <- data.frame(
x = 1:100,
y_raw = c(0, 0.1, 0.5, 1, 5, 10, 50, 100, 500, 1000, sample(1:2000, 90, replace = TRUE))
)
# Plot with y-axis on LL4 scale
ggplot(df, aes(x = x, y = y_raw)) +
geom_point() +
scale_ll4(name = "Y-axis (LL4 Scale)", lambda = 4) +
ggtitle("Data with LL4 Transformed Y-Axis")
# Can also be used for x-axis by replacing scale_y_continuous in its definition
# Or by creating a scale_x_ll4 variant.
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.