Black Lives Matter. Please consider donating to Black Girls Code today.

Garbage comes for two line chart

I need to draw multiple graph. Here is my code:

import plotly.graph_objects as go
import pandas as pd

df_usgsn03 = pd.read_csv('Graph_Data/MME/USGSN03/mme.txt',sep='|')
df_usgsn04 = pd.read_csv('Graph_Data/MME/USGSN04/mme.txt',sep='|')

fig = go.Figure()
fig.add_trace(go.Scatter(
                x=df_usgsn03['Measurement Time'],
                y=df_usgsn03['VS.MM.TaLaMisconfigurationMscSupervision'].diff(),
                ))

fig.add_trace(go.Scatter(
                x=df_usgsn04['Measurement Time'],
                y=df_usgsn04['VS.MM.TaLaMisconfigurationMscSupervision'].diff(),
                ))


fig.show()

But getting this output:

But if i see one grah… it is ok:

Hi @enarban, welcome to the forum! The problem comes from your second trace, but I don’t think it is due to the fact that you have two traces (have you tried visualizing only trace 1?). Probably the x data in your second dataset are not sorted, hence the “jagged” aspect. You can sort the data first (https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.sort_values.html).

For more : https://stackoverflow.com/questions/60512422/multiple-csv-files-in-plotly-chart

If I see one by one… graphs look ok.

CSV files:
https://gofile.io/?c=g0vztw

I think number of row must be equal for line chart. Here not equal thats why I see this pequlier.
What do you think?

Found the issue.
Problem is the Measure Time value.
I excluded second part from the measure time…Then it became ok.
I modified it like:

pd.to_datetime(df_usgsn03[‘Measurement Time’]).apply(lambda t: t.replace(second=0)

Thanks everybody.