Plotly R:突出显示饼图中的悬停标签,并灰色其他标签
DataFrame:
df2 = data.frame(value = c(9, 2, 7, 3, 6),
key = c('ar', 'or', 'br', 'gt', 'ko'))
这是生成饼图的代码:
df2 %>%
plot_ly(labels = ~key,
values = ~value,
type = 'pie')
基本上,我想突出显示我正在悬停并灰色的标签,例如这些图: 1st plot 和。
有办法这样做吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我使用了一个灰色和默认的颜色数组,并将您悬停在所有灰色数组中的替代品中使用的点,然后将其作为
plotly_restyle
发送到图形。如果您熟悉updatemenus
适用于按钮的方法,那么它本质上是相同的编码,仅在JS而不是R。 “ rel =“ nofollow noreferrer”>
I used a gray and default color array and used the point you hover on as a replacer in the array of all gray colors, then it's sent to the graph as a
plotly_restyle
. If you're familiar with howupdatemenus
works for buttons, it's essentially the same coding, just in JS instead of R.