0

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 enter image description here

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

enter image description here

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?

  • Related: https://stackoverflow.com/questions/3682748/converting-unix-timestamp-string-to-readable-date – foglerit Feb 06 '21 at 23:05
  • Please don't add code and data as image. [Why not upload images of code/errors when asking a question?](https://meta.stackoverflow.com/questions/285551/why-not-upload-images-of-code-errors-when-asking-a-question) – JohanC Feb 07 '21 at 00:08
  • Sorry. I don´t know how to do it with Jupyter Notebook, bringing the code and the results! – Carlos Augusto Frana Schettini Feb 10 '21 at 17:11

1 Answers1

0

Working further with this data... I found this other strange behavior!

I have the time_dt, created with matplotlib.dates.num2date() and I have the time_dt2, created just with datetime.datetime()

Making a plot for the same variable with the two time arrays, I got this enter image description here

So, it seems that time_dt and time_dt2 are about the same.

When I do this enter image description here

This is my expected result from the begging. But... when I do this enter image description here

The pcolormesh is gone, no error! Quite weird...