You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
dates.date2num bug with daylight switching hour #3896
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()
Activity
Fix problem with inconsistent time zones. This now also fixes Issue m…
tacaswell commentedon Feb 7, 2015
Has proposed fix in #3947
tacaswell commentedon Mar 21, 2016
The fix in #3947 does not seem to fix this on master (but the default tick labels look better!)