Skip to content
Advertisement

Why time zone conversation doesn’t affect the figure in plotting datetime objects in matplotlib?

I’m trying to plot a figure in which dates, without times, are in x-axis and times, without dates, are in y-axis:

JavaScript

The above code works well. However when I convert time zones from UTC to US/Eastern I get the same result, as if I did nothing.

JavaScript

The result of both before and after time zone conversation:

enter image description here

When I print, for example, first element of the list times before and after conversation I get different and the desired result. So the conversation works well:

JavaScript

Advertisement

Answer

to get a correct localization of the time, I suggest to combine the date from your dates list with the time from your times list – assuming they belong together! otherwise, localization will most likely be incorrect for the date 1900-1-1.

JavaScript

now the plot works as expected:

JavaScript

enter image description here

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement