我是一个长期的ggplot2用户,但是很新的情节。我目前正在研究比率图(例如,来自Cox比例风险模型)。我想对比例进行对数转换,但是当我这样做然后使用ggplotly()时,工具提示会显示转换后的值而不是原始值(例如,对于比值比为1,它会显示0)。
有没有办法让ggplotly()显示原始值? originalData
论证似乎不是我想要的,我找不到其他任何线索。
示例:
library(plotly)
library(ggplot2)
df <- data.frame(x = 1:10,
ref.level = 1,
or = seq(from = 1, by = 0.25, length.out = 10),
lcl = c(1, seq(from = 1.1, by = 0.1, length.out = 9)),
ucl = c(1, seq(from = 1.35, by = 0.35, length.out = 9)))
ggobj <- ggplot(data = df, aes(x = x, y = or)) +
geom_pointrange(aes(ymin = lcl, ymax = ucl))
ggobj %>% ggplotly()
## Plot ratios on log scale
ggobj <- ggobj +
scale_y_continuous(trans = 'log')
## Plot with ggplotly(); y, ymin, ymax tooltips are on transformed scale
ggobj %>% ggplotly()