Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 19a06a3

Browse files
committed
manage locators not deriving from LocatorBase
1 parent d568db6 commit 19a06a3

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

lib/matplotlib/axis.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -890,14 +890,20 @@ def iter_ticks(self):
890890
Iterate through all of the major and minor ticks.
891891
"""
892892
majorLocs = self.major.locator()
893-
hasLabel = self.major.locator.show_tick_label(majorLocs)
893+
try:
894+
hasLabel = self.major.locator.show_tick_label(majorLocs)
895+
except AttributeError:
896+
hasLabel = np.ones(np.asarray(majorLocs).size, dtype=np.bool)
894897
majorTicks = self.get_major_ticks(len(majorLocs))
895898
self.major.formatter.set_locs(majorLocs)
896899
majorLabels = [self.major.formatter(val, i) if hasLabel[i] else ''
897900
for i, val in enumerate(majorLocs)]
898901

899902
minorLocs = self.minor.locator()
900-
hasLabel = self.major.locator.show_tick_label(minorLocs)
903+
try:
904+
hasLabel = self.major.locator.show_tick_label(minorLocs)
905+
except AttributeError:
906+
hasLabel = np.ones(np.asarray(minorLocs).size, dtype=np.bool)
901907
minorTicks = self.get_minor_ticks(len(minorLocs))
902908
self.minor.formatter.set_locs(minorLocs)
903909
minorLabels = [self.minor.formatter(val, i) if hasLabel[i] else ''

lib/matplotlib/ticker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1625,7 +1625,7 @@ def show_tick_label(self, ticklocs):
16251625
numdec = abs(vmax - vmin)
16261626

16271627
if numdec > 3:
1628-
sublabel = set((1))
1628+
sublabel = set((1,))
16291629
elif numdec > 2:
16301630
sublabel = set((1, 3))
16311631
elif numdec > 1:

0 commit comments

Comments
 (0)