悬停信息显示在绘图直方图 R 中的条形上方
我正在尝试使用Plotly创建直方图,但是当我定义“ Hoverinfo”信息时,它会在栏上显示信息,而不是“内部”。
diamonds %>% plot_ly(x = ~cut, color = ~clarity, hoverinfo = 'text', text = ~carat)
我尝试使用add_histogram()
,但似乎没有任何作用。我应该怎么办?
I'm trying to create an histogram with plotly, but when I define the 'hoverinfo' information, it displays the information over the bars and not 'inside'.
diamonds %>% plot_ly(x = ~cut, color = ~clarity, hoverinfo = 'text', text = ~carat)
I tried to use add_histogram()
as well, but nothing seems to work. What should I do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我对您的评论很感兴趣,因为您拥有最新的
plotly
版本,因此我下载了它并且可以复制您的问题。看来在plotly.js
中处理默认text
参数的方式发生了变化,请参阅 此处:不幸的是,当
type="histogram"
时,没有textposition
参数。在您的情况下解决此问题的方法是将text
参数替换为hovertext
:I was intrigued by your comment that you had the most recent
plotly
version, so I downloaded it and I could replicate your issue. It looks like there has been a change in the way the defaulttext
argument is treated inplotly.js
, see here:Unfortunately, when
type="histogram"
, there is notextposition
argument. The way to fix this in your case is to replace thetext
argument withhovertext
: