使用Plotly与R的Hovermode [英] Hovermode using Plotly with R

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

问题描述

在使用R和ggplot2绘图时,有没有办法编写hovermode?



目前,我的代码是:

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

我想让plotly graph自动将悬停模式设置为在悬停时显示最接近的数据,而不是悬停时比较数据。


<在调用 ggplotly 时添加以下参数:



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


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

Currently, my code is:

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

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".

解决方案

Add the following argument when calling ggplotly:

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

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

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