I'm processing time series from some instruments, and the numbers came in different patterns.
Sometimes I have the time as year, month, day, hour, etc., and I create the datetime array/list directly. When I print one element of the array (or list) created, I have something like this
datetime.datetime(2018, 4, 6, 12, 0, 0)
2018-04-06 12:00:00
And when I use it with matploblib.pcolormesh
, it works.
However, now I have the time as 'seconds since 1970/1/1'. My first try was doing this
And I can use the array time_dt
with plt.plot()
, but when I use it with plt.pcolormesh()
I got
TypeError: Incompatible X, Y inputs to pcolormesh; see help(pcolormesh)
After checking and re-checking everything, the only difference was the way I create the datetime array using matplotlib.dates
, I guess. When I create a time list using this
everything goes fine! In the present case, I can go this way. But in other cases I can't create the time array and must convert from the files from variable sources... I need to understand what's going on.
What's happening? What do I missing?