Skip to content

Commit 6ac74e5

Browse files
committed
FIX: revert part of pandas-dev#11770
Reverts part of: pandas-dev#11770 Closes: matplotlib/matplotlib#6365 The mistake in pandas-dev#11770 was missing that pandas had a 1/us not 1/s scaled bucket.
1 parent 4aa6323 commit 6ac74e5

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

doc/source/whatsnew/v0.18.2.txt

+1-4
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,4 @@ Bug Fixes
143143

144144

145145

146-
147-
148-
149-
146+
- Bug in ``AutoDataFormatter``, restore second scaled formatting and readd musecond scaled formatting (:issue:`13131`)

pandas/tseries/converter.py

+18
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from dateutil.relativedelta import relativedelta
66

7+
import matplotlib
78
import matplotlib.units as units
89
import matplotlib.dates as dates
910

@@ -23,6 +24,16 @@
2324
from pandas.tseries.frequencies import FreqGroup
2425
from pandas.tseries.period import Period, PeriodIndex
2526

27+
# constants
28+
HOURS_PER_DAY = 24.
29+
MIN_PER_HOUR = 60.
30+
SEC_PER_MIN = 60.
31+
32+
SEC_PER_HOUR = SEC_PER_MIN * MIN_PER_HOUR
33+
SEC_PER_DAY = SEC_PER_HOUR * HOURS_PER_DAY
34+
35+
MUSEC_PER_DAY = 1e6 * SEC_PER_DAY
36+
2637

2738
def register():
2839
units.registry[lib.Timestamp] = DatetimeConverter()
@@ -221,6 +232,13 @@ def __init__(self, locator, tz=None, defaultfmt='%Y-%m-%d'):
221232
if self._tz is dates.UTC:
222233
self._tz._utcoffset = self._tz.utcoffset(None)
223234

235+
# For mpl > 2.0 the format strings are controlled via rcparams
236+
# so do not mess with them. For mpl < 2.0 change the second
237+
# break point and add a musec break point
238+
if matplotlib.compare_versions('2.0.0', matplotlib.__version__):
239+
self.scaled[1. / SEC_PER_DAY] = '%H:%M:%S'
240+
self.scaled[1. / MUSEC_PER_DAY] = '%H:%M:%S.%f'
241+
224242

225243
class PandasAutoDateLocator(dates.AutoDateLocator):
226244

0 commit comments

Comments
 (0)