[英]ggplotly: rename tooltip on hover
这是一种方法。
library(plotly)
library(scales) # for the number() function
gg <- ggplot(dplyr::as_tibble(rnorm(1000)), aes(value)) +
stat_ecdf(geom = 'line')
ggly <- ggplotly(gg)
text_x <- number(
ggly$x$data[[1]]$x,
prefix = "Unit Price: $",
accuracy = 0.01
)
text_y <- number(
ggly$x$data[[1]]$y,
scale = 100,
accuracy = 0.1,
prefix = "Cumul. distribution: ",
suffix = "%"
)
ggly %>%
style(text = paste0(text_x, "</br></br>", text_y), traces = 1)
你可以给你 plotly package。 这是一篇文章,告诉您如何添加自定义工具提示Plotly
嗯,更改 aes 似乎是我们可以修改标签的唯一方法,它不完全支持您现在想要的
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.