我知道跟踪(标记/线)有 hovertemplate/hover_text/ 选项,但我找不到形状这样的东西。有没有办法在形状上移动时弹出悬停文本?也许是一种解决方法?
例子:
import plotly.graph_objects as go
fig = go.Figure()
fig.add_trace(go.Scatter(
x=[1.5, 3],
y=[2.5, 2.5],
text=["Rectangle reference to the plot",
"Rectangle reference to the axes"],
mode="markers",
))
fig.add_shape(
# Rectangle reference to the plot
type="rect",
xref="paper",
yref="paper",
x0=0.25,
y0=0,
x1=0.5,
y1=0.5,
line=dict(
color="LightSeaGreen",
width=3,
),
fillcolor="PaleTurquoise",
)
Run Code Online (Sandbox Code Playgroud)
当我将鼠标悬停在这两点上时,我会得到一个包含信息的悬停模板。我怎样才能得到形状相似的东西?
我想修改绘图直方图的悬停模板。到目前为止,无法找到一种方法: 对给定的值进行舍入 删除直方图的名称(此处:“2012”、“2013”) 添加名称以指示值代表什么
所需的悬停文本:
Bin-range: -1.24, 3.31
Run Code Online (Sandbox Code Playgroud)
或者
更好的选择(带连字符的范围):
Bin-range: -1.24 - 3.31
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
import plotly.figure_factory as ff
import numpy as np
import pandas as pd
df = pd.DataFrame({'2012': np.random.randn(200),
'2013': np.random.randn(200)+1})
fig = ff.create_distplot([df[c] for c in df.columns],
df.columns, bin_size=.25, show_rug=False)
fig.show()
Run Code Online (Sandbox Code Playgroud) 我想在图中创建额外的注释空间(请参阅附图中的绿色区域)。目前,y 轴定义了绘图的高度。我可以将绘图推到超出 y.max 限制/在某个点(在图像中标记为红色)之后隐藏 y 轴吗?我尝试避免轴到达“评论部分”(绿色)。
谢谢你!