Reputation: 5883
Is there a to way to adjust annotation_logticks()
in ggplot2
to work with log1p
transformation?
Example:
library("ggplot2")
df <- data.frame(trt = c("a", "b", "c"), outcome = c(5, 10, 30))
p <- ggplot(df, aes(trt, outcome)) + geom_col()
This produces the desired results:
p + scale_y_continuous(trans = "log") +
annotation_logticks(base = exp(1), sides = "l")
This does not (notice the two sets of ticks do not line up):
p + scale_y_continuous(trans = "log1p") +
annotation_logticks(base = exp(1), sides = "l")
Upvotes: 2
Views: 1353
Reputation: 4551
Use breaks
within scale_y_continuous
:
p + scale_y_continuous(trans = "log1p", breaks = c(1, 5, 10, 20))
Upvotes: 2