I would like to do inverse of log2 transform on my coordinates only.
From what I understand, exp_trans() and log_trans() go together, so
gg.plot +
coord_trans(x="exp")
would perform inverse of log on the coordinates.
However, I noticed there is nothing like 2_trans() for log2_trans().
What are my options?
One option is to use scales::exp_trans(base =...)
as a function instead of by name. Demonstrated for the y-axis below. The default break calculations are not that pretty with coord_trans()
. Note that there are warnings about infinite values, but these are likely the expanded axis limits that go below the [0, Inf]
domain for log-transforms.
library(ggplot2)
ggplot(pressure, aes(temperature, pressure)) +
geom_line() +
scale_y_log10() +
coord_trans(y = scales::exp_trans(10))
#> Warning in trans$inverse(continuous_range_coord): NaNs produced
#> Warning in self$trans$y$inverse(panel_params$y.range): NaNs produced
Created on 2021-01-11 by the reprex package (v0.3.0)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.