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

Skip to content

Commit cb5042d

Browse files
committed
BUG: Check scale for AutoMinorLocator and throw a warning if not linear
1 parent 590f042 commit cb5042d

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

lib/matplotlib/ticker.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1924,8 +1924,7 @@ def __init__(self):
19241924
class AutoMinorLocator(Locator):
19251925
"""
19261926
Dynamically find minor tick positions based on the positions of
1927-
major ticks. Assumes the scale is linear and major ticks are
1928-
evenly spaced.
1927+
major ticks. The scale must be linear with major ticks evenly spaced.
19291928
"""
19301929
def __init__(self, n=None):
19311930
"""
@@ -1939,6 +1938,10 @@ def __init__(self, n=None):
19391938

19401939
def __call__(self):
19411940
'Return the locations of the ticks'
1941+
if self.axis.get_scale() != 'linear':
1942+
warnings.warn('AutoMinorLocator only works with linear scale')
1943+
return []
1944+
19421945
majorlocs = self.axis.get_majorticklocs()
19431946
try:
19441947
majorstep = majorlocs[1] - majorlocs[0]

0 commit comments

Comments
 (0)