-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Off-by-one bug in annual axis labels when localized time crosses year boundary #12675
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
A workaround is to set the
But that's sure not a sustainable solution. I wonder if this goes deeper, because without the time zone it works fine. |
Yeah, I think #9801 just made the real bug more apparent by changing the default |
OK, this seems to be either a import pytz
from datetime import datetime, timedelta, timezone
UTC = timezone.utc
date0 = datetime(2010, 1, 1, tzinfo=pytz.timezone('US/Pacific'))
print('date0 ', date0)
dateUTC = date0.astimezone(tz=UTC)
print('dateUTC ', dateUTC)
dateLocal = dateUTC.astimezone(tz=pytz.timezone('US/Pacific'))
print('datelocal', dateLocal) yields:
|
Ah, OK, you can't do:
but you can do:
Doing date0 = datetime(2010, 1, 1, 0,0,0).astimezone(pytz.timezone('US/Pacific'))
print('date0 ', date0)
dateUTC = date0.astimezone(tz=UTC)
print('dateUTC ', dateUTC)
dateLocal = dateUTC.astimezone(tz=pytz.timezone('US/Pacific'))
print('datelocal', dateLocal) yields a good round trip..
OTOH, the bug described above is still an issue... |
OK, thanks for the bug report - there was a tz argument not being passed through. Fixed in #12678 |
Bug report
Bug summary
When plotting dates with time zone information on the x-axis, under certain circumstances, the wrong year will be displayed as the label.
Code for reproduction
Actual outcome
The first label on the plot is 2009.
Expected outcome
The first label on the plot is 2010.
Matplotlib version
Built this morning from master. Also confirmed the issue on 3.0.0 and confirmed that 2.2.2 does not have the issue (or at least not with the reproduction steps I found.)
I built matplotlib from source to verify that this bug affects master. The checks against 3.0.0 and 2.2.2 were done on a conda install of those versions and may have had different versions of pytz and jupyter.
The text was updated successfully, but these errors were encountered: