从 plotly 对象中删除悬停信息文本

标签 r hover plotly

我正在 R 中创建一个 plotly 对象:

library(plotly)
p <- plot_ly(data = iris, x = ~Sepal.Length, y = ~Petal.Length, text = ~Species, hoverinfo="text",
             marker = list(size = 10,
                           color = 'rgba(255, 182, 193, .9)',
                           line = list(color = 'rgba(152, 0, 0, .8)',
                                       width = 2))) %>%
  layout(title = 'Styled Scatter',
         yaxis = list(zeroline = FALSE),
         xaxis = list(zeroline = FALSE))

如您所见,它包含 hoverino

然后在某个时候我想删除那个 hoverinfo 层。

知道怎么做吗?

最佳答案

style(hoverinfo = 'none')

所以把它们放在一起:

(p <- plot_ly(data = iris, x = ~Sepal.Length, y = ~Petal.Length, text = ~Species, hoverinfo="text",
             marker = list(size = 10,
                           color = 'rgba(255, 182, 193, .9)',
                           line = list(color = 'rgba(152, 0, 0, .8)',
                                       width = 2))) %>%
  layout(title = 'Styled Scatter',
         yaxis = list(zeroline = FALSE),
         xaxis = list(zeroline = FALSE)) %>% 
  style(hoverinfo = 'none'))

关于从 plotly 对象中删除悬停信息文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53787679/

相关文章:

r - 理解 R-Hive、Elastic MapReduce、RHIPE 和使用 R 的分布式文本挖掘

python - Plotly:如何使用 plotly express 为多个轨迹设置标记符号形状?

r - 将包含字符和数字的列分隔为每个类别的两个单独的列

r - 如何在整列的特定位置添加数值?

javascript - 如何临时存储和禁用另一个元素的事件

html - :hover not working

php - 悬停在 Div 上时查询 MySql

python - Plotly:如何绘制累积的 "steps"直方图?

python - 如何删除 x 轴的垂直线并向绘图子图添加标签?

R For 循环无法应用 max 函数