Unintended Additional line drew by Plotly express

Plotly draws an extra diagonal line from the start to the endpoint of the original line graph.

Other data, other graphs work fine.

Only this data adds the line.

Why does this happen?

How can I fix this?

Below is the code

temp = pd.DataFrame(df[{KEY_WORD}])
temp['date'] = temp.index
fig=px.line(temp.melt(id_vars="date"), x='date', y='value', color='variable')
fig.show()
plotly.offline.plot(fig,filename='Fig_en1')

Hi @jadhvank,

Sorting the dataframe by date should do the work

temp = pd.DataFrame(df[{KEY_WORD}])
temp['date'] = temp.index
fig=px.line(temp.melt(id_vars="date").sort_values('date'), x='date', y='value', color='variable')
fig.show()
plotly.offline.plot(fig,filename='Fig_en1')

hope this helps

Alex -

1 Like