This questions explains how to use datetime
objects on x axis:
Dates in the xaxis for a matplotlib plot with imshow
and that works perfectly.
But what I have is measurement data which correspond to different time intervals of 1 minute or 3 minutes and there are also gaps in the data of varying durations - 10 minutes or 1 hour or anything in between. Data is in a dictionary with datetime keys and numpy array values. Some of the keys are 1 min and some are 3 min apart. There are also gaps in the the data which are > 3min, usually not < 10 min.
If I plot this with:
ax.imshow(arr, extent = [x1, x2, y1, y2], aspect='auto')
where x1 and x2 are start and end times and y1 and y2 vertical dimension, and arr is 2d numpy array generated form the dictionary values mentioned above,
the data will be evenly spread across the time axis, and I want gaps to be visible, and I want data to be plotted with regard to its time resolution and time of measurement.
I thought of writing nans
to my array to fill the gaps, but then I would also have to copy data of 3 min time step to fill the 'gaps' because most of the data is available each minute.
I am looking for a better and more elegant option. Of course I do not have to use imshow()
if there is another way.