I have a bunch of measurements over time and I want to plot them in R. Here is a sample of my data. I\'ve got 6 measurements for each of 4 time points:
value
A work around to solve it, if you don´t want to use coord_trans() and still want to transform the data, is to create a function which will back transform it:
f1 <- function(x) {
log10(mean(10 ^ x))
}
stat_summary (fun.y = f1, geom="line", mapping = aes (group = 1))
The best solution I found for this issue was to use a combo of coord_trans()
and scale_y_continuous(breaks = breaks)
As previously suggested, using coord_trans
will scale your axis without transforming the data, however it will leave you with an ugly axis.
Setting the limits in coord_trans
works for some things, but if you want to fix your axis to have specific labels, you will then include scale_y_continuous
with the breaks you'd like set.
coord_trans(y = 'log10') +
scale_y_continuous(breaks = breaks)
scale_y_log2()
will do the transformation first and then calculate the geoms.
coord_trans()
will do the opposite: calculate the geoms first, and the transform the axis.
So you need coord_trans(ytrans = "log2")
instead of scale_y_log2()