[英]How to remove unexpected hover value in Plotly Express bar plot, Python
I am using plotly express for creating a horizontal bar plot. After adding hovertamplate
, an ugly zero appeared in hover box (always a zero for each element).我正在使用 plotly express 创建单杠 plot。添加hovertamplate
后,hover 框中出现一个丑陋的零(每个元素始终为零)。 What is it and how can I get rid of it?它是什么,我怎样才能摆脱它? Thanks.谢谢。
fig = px.bar(df, orientation = 'h')
fig.update_traces(hovertemplate = "%{label}, in %{value} drugs")
Solution found here if any one needs it, too:如果有人需要,也可以在这里找到解决方案:
"...need to add <extra></extra>
at the end of the hovertemplate
, as here . The <extra>
tag is for the second part of the hover, in a different color, where usually the trace name is displayed." “...需要在hovertemplate
的末尾添加<extra></extra>
,如此处。 <extra>
标记用于 hover 的第二部分,颜色不同,通常显示跟踪名称”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.