8000 Updatefmt with loc - introduce private locator setter · matplotlib/matplotlib@5dffdd1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5dffdd1

Browse files
Updatefmt with loc - introduce private locator setter
1 parent c62ea13 commit 5dffdd1

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

lib/matplotlib/axis.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1567,8 +1567,6 @@ def set_minor_formatter(self, formatter):
15671567
"matplotlib.ticker.Formatter")
15681568
self.isDefault_minfmt = False
15691569
self.minor.formatter = formatter
1570-
if hasattr(self.minor.formatter, "_ismajor"):
1571-
self.minor.formatter._ismajor = False
15721570
formatter.set_axis(self)
15731571
self.stale = True
15741572

@@ -1585,6 +1583,8 @@ def set_major_locator(self, locator):
15851583
"matplotlib.ticker.Locator")
15861584
self.isDefault_majloc = False
15871585
self.major.locator = locator
1586+
if self.major.formatter:
1587+
self.major.formatter._set_locator(locator)
15881588
locator.set_axis(self)
15891589
self.stale = True
15901590

@@ -1601,6 +1601,8 @@ def set_minor_locator(self, locator):
16011601
"matplotlib.ticker.Locator")
16021602
self.isDefault_minloc = False
16031603
self.minor.locator = locator
1604+
if self.minor.formatter:
1605+
self.minor.formatter._set_locator(locator)
16041606
locator.set_axis(self)
16051607
self.stale = True
16061608

lib/matplotlib/dates.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,6 @@ def __init__(self, locator, tz=None, defaultfmt='%Y-%m-%d'):
806806
returned by ``locator._get_unit()``.
807807
"""
808808
self._locator = locator
809-
self._ismajor = True
810809
self._tz = tz
811810
self.defaultfmt = defaultfmt
812811
self._formatter = DateFormatter(self.defaultfmt, tz)
@@ -821,13 +820,10 @@ def __init__(self, locator, tz=None, defaultfmt='%Y-%m-%d'):
821820
1. / (MUSECONDS_PER_DAY):
822821
rcParams['date.autoformatter.microsecond']}
823822

823+
def _set_locator(self, locator):
824+
self._locator = locator
825+
824826
def __call__(self, x, pos=None):
825-
# Check if locator is still the one from the axis to format
826-
if hasattr(self.axis, "get_major_locator"):
827-
pot_locator = self.axis.get_major_locator() if self._ismajor \
828-
else self.axis.get_minor_locator()
829-
if self._locator is not pot_locator:
830-
self._locator = pot_locator
831827
try:
832828
locator_unit_scale = float(self._locator._get_unit())
833829
8F2F except AttributeError:

lib/matplotlib/ticker.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,10 @@ def fix_minus(self, s):
301301
"""
302302
return s
303303

304+
def _set_locator(self, locator):
305+
""" Subclasses may want to override this to set a locator. """
306+
pass
307+
304308

305309
class IndexFormatter(Formatter):
306310
"""

0 commit comments

Comments
 (0)
0