Currently I am using plotly in R, and I wonder what code should I use to log2 transform one of the axes ?
Thank you very much for your answer!
Currently I am using plotly in R, and I wonder what code should I use to log2 transform one of the axes ?
Thank you very much for your answer!
Here is an example to do log transform on the x-axis. However, I don't know if it is possible to do log2.
library(plotly)
mtcars %>%
  plot_ly(x = ~disp, y = ~mpg) %>%
  add_markers(marker = list(opacity = 0.8)) %>%
  layout(xaxis = list(type = "log"))
An alternative is to use ggplot2 with scale_x_continuous with trans = "log2", and then ggplotly
library(ggplot2)
p <- ggplot(mtcars, aes(x = disp, y = mpg)) +
  geom_point() +
  scale_x_continuous(trans = "log2")
ggplotly(p)
