import plotly.graph_objects as go
fig = go.Figure()
x = np.array([0,1,2,3])
x_s = np.array([0,1,2,3])
y = np.array([1,1,2,3])
y_s = np.array([0,0,0,0])
fig.add_trace(go.Scatter(
x=x_s,
y=y_s,
name='Test',
marker=dict(
size=10,
cmax=1,
cmin=0,
color='black',
colorscale="Rainbow_r",
symbol='circle'
# line=dict(color=line_colors, width=3)
),
showlegend=True,
hoverinfo='text',
hoverlabel=dict(bgcolor="white", font_color="black"),
mode='markers',
textposition="top center"))
fig.add_annotation(
x=0,
y=1,
ax=0,
ay=0,
xref='x',
yref='y',
axref='x',
ayref='y',
text='xxxx',
showarrow=True,
arrowhead=3,
arrowsize=1,
arrowwidth=1,
arrowcolor='black'
)
此代码生成以下图表:
有没有可能这样做,当你点击标记的图例时,箭头就会随之消失?
阅读https://plotly.com/python/text-and-annotations/和https://plotly.com/python/legend/.