I\'m attempting to use a custom scale/axis transformation, like so:
library(ggplot2)
library(scales)
dat <- data.frame(
time.tot = c(407.17, 168.83, 12
You may need to set the scale on the y axis directly:
ggplot(dat, aes(x=time.tot, y=error, color=type)) +
geom_line() + geom_point() + coord_trans(y = tn)
+ scale_y_continuous(breaks = c(0,0.1,1))
Also, the non-straight lines are the expected behavior of coord_trans
. from the help: "coord_trans is different to scale transformations in that it occurs after statistical transformation and will affect the visual appearance of geoms - there is no guarantee that straight lines will continue to be straight."
Instead, try:
b <- 10^-c(Inf, 8:0)
ggplot(dat, aes(x=time.tot, y=error, color=type)) +
geom_line() + geom_point() + scale_y_continuous(breaks = b, labels=b, trans = tn)