考虑以下 MWE:
import plotly.graph_objects as go
fig = go.Figure()
for i in range(4):
fig.add_trace(
go.Scatter(
x = [1,2,3],
y = [i]*3,
name = 'A very long legend<br>which I break in<br>multiple lines'
)
)
fig.write_html('deleteme.html')