Skip to content Skip to sidebar Skip to footer

Plotting With Time Axis (python)

I ran into a problem again thats causing me headache for several hours already...and I'm pretty sure it's just a minor thing. I got a long datafile and created a list with the head

Solution 1:

In pylab.plot(dt, XXX) you're trying to plot the imported datetime module itself against a list of values, which is not what you want.

Instead you want something like pylab.plot(times, XXX) where times should be a list containing the datetime objects corresponding to the list XXX.

The error message you are getting is pointing out the 2 arguments you pass to the plot function should be lists of the same length.

See Plotting time in Python with Matplotlib for further information including formatting the x-axis labels.

Post a Comment for "Plotting With Time Axis (python)"