Home > Software design >  wrong time and resolution axis when plotting time series (secs instead of min)
wrong time and resolution axis when plotting time series (secs instead of min)

Time:05-17

I want to plot a DataFrame as a time series

import matplotlib.pyplot as plt
plt.plot(df['time'],df['Power'])

or

df2 = df.set_index('time')
df2.Power.plot()

which both show all 3531 y values correctly but wrong x axis time labels, like 25 seconds instead of 25 minutes.

enter image description here

timestamps are not completely regular and have ms decimals

0      2022-05-16 19:59:25.690
1      2022-05-16 19:59:25.890
2      2022-05-16 19:59:26.100
3      2022-05-16 19:59:26.320
4      2022-05-16 19:59:26.530
                 ...          
3526   2022-05-16 20:24:51.690
3527   2022-05-16 20:24:52.420
3528   2022-05-16 20:24:52.740
3529   2022-05-16 20:24:53.210
3530   2022-05-16 20:24:54.570

Name: time, Length: 3531, dtype: datetime64[ns]

what am I missing?

CodePudding user response:

You should use enter image description here

  • Related