我正在尝试使用以下代码在 x_axis 下方绘制一个箭头:
myplot = go.Figure(data=go.Scatter(x=df['time'], y=df['count'], mode='markers'))
xstart = -2
xmax = 3.5
xmin = -3.5
padding = 0.05
ypos = -0.1
mylplot.update_layout(
plot_bgcolor=colors['backgraph'],
paper_bgcolor=colors['backpaper'],
font_color=colors['text'],
showlegend=False,
width=550,
height=550,
xaxis=dict(title_text="Time", showgrid=False, showticklabels=False),
yaxis=dict(title_text="Counts", showgrid=False, showticklabels=False),
annotations=[dict(
x=xmin,
y=ypos,
ax=xstart + padding,
ay=ypos,
xref='x',
axref='x',
yref='paper',
ayref='paper',
showarrow=True,
arrowhead=2,
arrowsize=1,
arrowwidth=3,
arrowcolor='#0000ff',
)],
但我收到以下错误:
ValueError:
Invalid value of type 'builtins.str' received for the 'ayref' property of layout.annotation
Received value: 'paper'
The 'ayref' property is an enumeration that may be specified as:
- One of the following enumeration values:
['pixel']
- A string that matches one of the following regular expressions:
['^y([2-9]|[1-9][0-9]+)?$']```
如果将ayref 设置为y,则箭头不显示。
我尝试运行此示例,但出现相同的错误。