Skip to content

dates.date2num bug with daylight switching hour #3896

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

Closed
kdebrab opened this issue Dec 6, 2014 · 2 comments
Closed

dates.date2num bug with daylight switching hour #3896

kdebrab opened this issue Dec 6, 2014 · 2 comments
Assignees
Milestone

Comments

@kdebrab
Copy link

kdebrab commented Dec 6, 2014

When plotting datetime values using date2num, something strange happens around the hour of daylight switching (matplotlib 1.4.2, pandas 0.15.1, numpy 1.9.1) as shown in the following graph:

import matplotlib.pyplot as plt
import datetime as dt
import pandas as pd
import pytz
from matplotlib.dates import date2num

dt64_utc = pd.date_range(start='2014/03/29 22:00', end='2014/03/30 6:00', freq='min', tz='UTC')
dtmpl_utc = date2num(dt64_utc.astype(dt.datetime))
dt64_bxl = dt64_utc.tz_convert(pytz.timezone('Europe/Brussels'))
dtmpl_bxl = date2num(dt64_bxl.astype(dt.datetime))
dtmpl_bxl_utc = date2num(dt64_bxl.tz_convert('UTC').astype(dt.datetime))
plt.plot(dtmpl_utc, dtmpl_bxl, 'g', label='implicit conversion to UTC by date2num')
plt.plot(dtmpl_utc, dtmpl_bxl_utc, 'b--', label='explicit conversion to UTC before calling date2num')
plt.gca().xaxis_date()
plt.gca().yaxis_date()
plt.grid()
plt.legend()

date2num bug

I assume this is a bug in date2num?

@tacaswell tacaswell added this to the v1.4.x milestone Dec 7, 2014
pganssle added a commit to pganssle/matplotlib that referenced this issue Dec 25, 2014
@tacaswell
Copy link
Member

Has proposed fix in #3947

@tacaswell tacaswell modified the milestones: v1.5.x, v1.4.x, 1.5.0 Feb 7, 2015
@tacaswell tacaswell modified the milestones: next point release, proposed next point release Jul 16, 2015
@tacaswell
Copy link
Member

The fix in #3947 does not seem to fix this on master (but the default tick labels look better!)

so

@tacaswell tacaswell self-assigned this Jul 25, 2016
@QuLogic QuLogic modified the milestones: 2.0 (style change major release), 2.1 (next point release) Jul 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants