The legend can be added by updating the layout to add a legend display. You can also add a stand-alone error bar to display a legend for the error bar.
import plotly.graph_objects as go
x_data = [1, 2, 3, 4, 5]
y_data = [10, 8, 6, 4, 2]
y2_data = [3, 5, 2, 8, 10]
fig = go.Figure()
fig.add_trace(go.Scatter(
x=x_data,
y=y_data,
mode='lines+markers',
name='Trace 1',
))
fig.add_trace(go.Scatter(
x=x_data,
y=y_data,
mode='markers',
name='error',
marker=dict(color='#636efa'),
error_y=dict(
type='data',
array=y2_data,
visible=True,
color='cyan'
)
))
fig.update_layout(
title='Simple Scatter Plot',
xaxis_title='X-Axis',
yaxis_title='Y-Axis',
showlegend=True
)
fig.show()