Search code examples
pythonplotlyplotly-dashplotly-pythonplotly-express

Using plotly.express line chart, lines are connecting in weird order? How to fix?


enter image description here

Having a df of data, doing:

fig=px.line(df, x='date', y='px', color='description') 

The following graph is rendered like the image attached. Is this an expected behavior? How do I make dots connect only in a time-ordered fashion?


Solution

  • Yes, this is observed in plotly plots.

    The data is required to be sorted before the plotting.