From cb5042d71c4d113e3fb82a50dd31f04d629dca7a Mon Sep 17 00:00:00 2001 From: Cimarron Mittelsteadt Date: Sat, 17 Oct 2015 16:20:30 -0700 Subject: [PATCH 1/2] BUG: Check scale for AutoMinorLocator and throw a warning if not linear --- lib/matplotlib/ticker.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/ticker.py b/lib/matplotlib/ticker.py index 5e09dde41b2..7b1b77137cd 100644 --- a/lib/matplotlib/ticker.py +++ b/lib/matplotlib/ticker.py @@ -1924,8 +1924,7 @@ def __init__(self): class AutoMinorLocator(Locator): """ Dynamically find minor tick positions based on the positions of - major ticks. Assumes the scale is linear and major ticks are - evenly spaced. + major ticks. The scale must be linear with major ticks evenly spaced. """ def __init__(self, n=None): """ @@ -1939,6 +1938,10 @@ def __init__(self, n=None): def __call__(self): 'Return the locations of the ticks' + if self.axis.get_scale() != 'linear': + warnings.warn('AutoMinorLocator only works with linear scale') + return [] + majorlocs = self.axis.get_majorticklocs() try: majorstep = majorlocs[1] - majorlocs[0] From 19baac5c23e337fcd4d34dc75cd7188ec44a915b Mon Sep 17 00:00:00 2001 From: Cimarron Mittelsteadt Date: Wed, 16 Dec 2015 16:14:40 -0800 Subject: [PATCH 2/2] Modified to blacklist log scale for AutoMinorLocator --- lib/matplotlib/ticker.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/ticker.py b/lib/matplotlib/ticker.py index 7b1b77137cd..6f1e35b7cfd 100644 --- a/lib/matplotlib/ticker.py +++ b/lib/matplotlib/ticker.py @@ -1938,8 +1938,9 @@ def __init__(self, n=None): def __call__(self): 'Return the locations of the ticks' - if self.axis.get_scale() != 'linear': - warnings.warn('AutoMinorLocator only works with linear scale') + if self.axis.get_scale() == 'log': + warnings.warn('AutoMinorLocator does not work with logarithmic ' + 'scale') return [] majorlocs = self.axis.get_majorticklocs()