You could use the layout attributes itemsizing
and itemwidth
:
import plotly.graph_objects as go
dict_of_fig = dict({
"data": [{"type": "scatter",
"x": [1, 2, 3],
"y": [1, 3, 2]}],
"layout": {"legend": {"itemsizing": "constant", "itemwidth": 100}}
})
fig = go.Figure(dict_of_fig)
fig.add_trace(go.Scatter(x=[1, 2, 3], y=[2, 3, 4]))
fig.show()