I have found coord_trans
, but I\'d like to apply log10
and
reverse
to my x-axis. I tried applying two transformation
ggplo
I wandered in here looking for a 'composition of scales' function. I think one might be able to write such a thing as follows:
# compose transforms a and b, applying b first, then a:
`%::%` <- function(atrans,btrans) {
mytran <- scales::trans_new(name = paste(btrans$name,'then',atrans$name),
transform = function(x) { atrans$transform(btrans$transform(x)) },
inverse = function(y) { btrans$inverse(atrans$inverse(y)) },
domain = btrans$domain, # this could use improvement...
breaks = btrans$breaks, # not clear how this should work, tbh
format = btrans$format)
}
ph <- ggplot(mtcars, aes(wt, mpg)) +
geom_point() +
scale_y_continuous(trans=scales::reverse_trans() %::% scales::log10_trans())
print(ph)