1

I have created a code which displays a graph along with legend. The legend by default is not in any specific order. I need to order it in ascending order. But did not get any useful link for that. Is there a way to do that?

import plotly.graph_objects as go
fig = go.Figure()
fig.add_trace(go.Scatter(x=time_list, y=list1,name="<b>" + entityName + "</b>", connectgaps=False))
fig.update_layout(showlegend=True, height=650, width=1400, title='<b>Availability</b>'
                  ,xaxis_title='<b>Date</b>', yaxis_title='<b>Percentage</b>')
fig.show()
0

1 Answer 1

0

You can use traceorder. An example would be:

layout = go.Layout(
   legend={'traceorder':'normal'})
)

You can view a more detailed explanation here.

Sign up to request clarification or add additional context in comments.

1 Comment

"normal" - the items are displayed top-to-bottom in the same order as the input data. Traceorder is not helping here.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.