我正在 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/