A third line when I only have two data points

import plotly.express as px

fig = px.line(what, x=‘year’, y=‘total’)
fig.show()

I have the following plotly graph. the data set looks like this

image

for some reason i’m getting this third line on the ploty graph when I only have two groups. Depression and Pain.

Anyone else have this issue?

Hi, you’re getting only one line actually, but it zigzags because your x data are not sorted. Use what.sort_values(by='year') to sort the dataframe first.

Thank you. That worked perfectly!

three reasons why you should buy plotly pro: support open source, get great support, host your plots and dashboards online