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

Skip to content

Commit ed1c830

Browse files
committed
FIX: make MaxNLocator only follow visible ticks for order of magnitude
1 parent 5e20d9b commit ed1c830

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/matplotlib/ticker.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,14 @@ def _set_orderOfMagnitude(self, range):
712712
# fixed scaling when lower power limit = upper <> 0.
713713
self.orderOfMagnitude = self._powerlimits[0]
714714
return
715-
locs = np.abs(self.locs)
715+
# restrict to visible ticks
716+
vmin, vmax = sorted(self.axis.get_view_interval())
717+
locs = np.asarray(self.locs)
718+
locs = locs[(vmin <= locs) & (locs <= vmax)]
719+
locs = np.abs(locs)
720+
if not len(locs):
721+
self.orderOfMagnitude = 0
722+
return
716723
if self.offset:
717724
oom = math.floor(math.log10(range))
718725
else:

0 commit comments

Comments
 (0)