Most tutorials I've seen for dealing with transforming log-based data involve using a log-based y-axis or x-axis scale. If I wanted to plot the log10 -based values of my data and indicate their relative actual exponent-based real values:
library(ggplot2)
library(scales)
a <- c(5,10,15,20)
b <- c(100,210,350,750)
d <- log10(b)
test_df <- data.frame(xval = a,yval = d)
test_plt <- ggplot(data = test_df,aes(x = xval,y = yval)) +
geom_point() +
scale_y_continuous(breaks = seq(1,3,by = 1),limits = c(1,3),labels = trans_format("log10",
math_format(10^.x)))
print(test_plt)
Based on the code, I get the following results:
Obviously, R is trying to convert the already log10-transformed values into log10 based values again, is there a way indicate that I want my y-axis tick values to be 101, 102, 103, etc. (ie: the the plotted values are log10 transformed, but the y-ticks indicate the actual values before the log10 transformation? Or am I approaching this problem incorrectly?


scales::math_format(format = log10)? - teunbrand