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

Skip to content

Commit fa3e3a1

Browse files
committed
manage locators not deriving from LocatorBase
1 parent 4b542fc commit fa3e3a1

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
@@ -883,14 +883,20 @@ def iter_ticks(self):
883883
Iterate through all of the major and minor ticks.
884884
"""
885885
majorLocs = self.major.locator()
886-
hasLabel = self.major.locator.show_tick_label(majorLocs)
886+
try:
887+
hasLabel = self.major.locator.show_tick_label(majorLocs)
888+
except AttributeError:
889+
hasLabel = np.ones(np.asarray(majorLocs).size, dtype=np.bool)
887890
majorTicks = self.get_major_ticks(len(majorLocs))
888891
self.major.formatter.set_locs(majorLocs)
889892
majorLabels = [self.major.formatter(val, i) if hasLabel[i] else ''
890893
for i, val in enumerate(majorLocs)]
891894

892895
minorLocs = self.minor.locator()
893-
hasLabel = self.major.locator.show_tick_label(minorLocs)
896+
try:
897+
hasLabel = self.major.locator.show_tick_label(minorLocs)
898+
except AttributeError:
899+
hasLabel = np.ones(np.asarray(minorLocs).size, dtype=np.bool)
894900
minorTicks = self.get_minor_ticks(len(minorLocs))
895901
self.minor.formatter.set_locs(minorLocs)
896902
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
@@ -1932,7 +1932,7 @@ def show_tick_label(self, ticklocs):
19321932
numdec = abs(vmax - vmin)
19331933

19341934
if numdec > 3:
1935-
sublabel = set((1))
1935+
sublabel = set((1,))
19361936
elif numdec > 2:
19371937
sublabel = set((1, 3))
19381938
elif numdec > 1:

0 commit comments

Comments
 (0)