A third line when I only have two data points

import plotly.express as px

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

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


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!