使用 Plotly 和 R 的悬停模式 [英] Hovermode using Plotly with R

查看:27
本文介绍了使用 Plotly 和 R 的悬停模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用 R 和 ggplot2 进行绘图时,有没有办法对悬停模式进行编码?

Is there a way to code the hovermode when using plotly with R and ggplot2?

目前,我的代码是:

plot <- ggplot(data, aes(var1, var2, text=var3)) + 
  geom_point()
py$ggplotly(plot)

我希望 plotly 图表自动将悬停模式设置为在悬停时显示最接近的数据"而不是在悬停时比较数据".

And I want the plotly graph to automatically have the hover mode set to "show closest data on hover" rather than "compare data on hover".

推荐答案

调用ggplotly时添加如下参数:

py$ggplotly(plot, kwargs=list(layout=list(hovermode="closest")))

这篇关于使用 Plotly 和 R 的悬停模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆