Matplotlib X-axis timezone trouble
Peter Pearson
pkpearson at nowhere.invalid
Tue Jun 30 00:49:06 EDT 2015
On Tue, 30 Jun 2015 12:11:31 +1000, Chris Angelico <rosuav at gmail.com> wrote:
> On Tue, Jun 30, 2015 at 10:56 AM, Peter Pearson
><pkpearson at nowhere.invalid> wrote:
>> The following code produces a plot with a line running from (9:30, 0) to
>> (10:30, 1), not from (8:30, 0) to (9:30, 1) as I desire.
>>
>> pacific = pytz.timezone("US/Pacific")
>> plt.plot([datetime.datetime(2014, 10, 7, 8, 30, tzinfo=pacific),
>> datetime.datetime(2014, 10, 7, 9, 30, tzinfo=pacific)],
>> [0,1], marker="o", color="green")
>
> Sounds to me like a bug in DST handling - in October 2014, Los Angeles
> was on Pacific Daylight Time, which would give a one-hour offset if
> matplotlib is handling things on the basis of Pacific Standard Time. I
> don't know if that helps at all with figuring out a solution, though.
Thanks, I think you're onto something. Points in a non-daylight-saving
month get plotted correctly:
plt.plot([datetime.datetime(2014, 12, 7, 8, 30, tzinfo=pacific),
datetime.datetime(2014, 12, 7, 9, 30, tzinfo=pacific)],
[0,1], marker="o", color="green")
Time zones teem with sneaky software problems, and so does daylight-saving
time, so this problem might strain my brain. Maybe it's going to turn
out that my expectations are unreasonable . . . as in, "Well, smarty pants,
how do you want the axis labelled when the abscissas straddle the
beginning of daylight-saving time?" I'll research and digest.
--
To email me, substitute nowhere->runbox, invalid->com.
More information about the Python-list
mailing list