From f76508dba157847cd2add8655332f765aec8b462 Mon Sep 17 00:00:00 2001 From: Trojan2498 Date: Tue, 28 May 2019 23:22:44 +0530 Subject: [PATCH 1/7] adding rcparams --- lib/matplotlib/rcsetup.py | 2 ++ lib/matplotlib/ticker.py | 4 ++-- matplotlibrc.template | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/rcsetup.py b/lib/matplotlib/rcsetup.py index 162b364bdbe5..97e15c101d45 100644 --- a/lib/matplotlib/rcsetup.py +++ b/lib/matplotlib/rcsetup.py @@ -1310,6 +1310,7 @@ def _validate_linestyle(ls): 'xtick.minor.bottom': [True, validate_bool], # draw x axis bottom minor ticks 'xtick.major.top': [True, validate_bool], # draw x axis top major ticks 'xtick.major.bottom': [True, validate_bool], # draw x axis bottom major ticks + 'xtick.minor.default': [4,validate_int], #set default value for x axis minor ticks # fontsize of the xtick labels 'xtick.labelsize': ['medium', validate_fontsize], @@ -1332,6 +1333,7 @@ def _validate_linestyle(ls): 'ytick.minor.right': [True, validate_bool], # draw y axis right minor ticks 'ytick.major.left': [True, validate_bool], # draw y axis left major ticks 'ytick.major.right': [True, validate_bool], # draw y axis right major ticks + 'ytick.minor.default': [4,validate_int], #set default value for y axis minor ticks # fontsize of the ytick labels 'ytick.labelsize': ['medium', validate_fontsize], diff --git a/lib/matplotlib/ticker.py b/lib/matplotlib/ticker.py index 337cda1a84f4..542a22adfcdd 100644 --- a/lib/matplotlib/ticker.py +++ b/lib/matplotlib/ticker.py @@ -2658,9 +2658,9 @@ def __call__(self): majorstep_no_exponent = 10 ** (np.log10(majorstep) % 1) if np.isclose(majorstep_no_exponent, [1.0, 2.5, 5.0, 10.0]).any(): - ndivs = 5 + ndivs = rcParams['xtick.minor.default'] + 1 else: - ndivs = 4 + ndivs = rcParams['xtick.minor.default'] else: ndivs = self.ndivs diff --git a/matplotlibrc.template b/matplotlibrc.template index cf1e810af740..fd1b10cc51ef 100644 --- a/matplotlibrc.template +++ b/matplotlibrc.template @@ -377,6 +377,7 @@ #xtick.minor.top : True ## draw x axis top minor ticks #xtick.minor.bottom : True ## draw x axis bottom minor ticks #xtick.alignment : center ## alignment of xticks +#xtick.minor.default : 4 ## set default value for x axis minor ticks #ytick.left : True ## draw ticks on the left side #ytick.right : False ## draw ticks on the right side @@ -397,6 +398,7 @@ #ytick.minor.left : True ## draw y axis left minor ticks #ytick.minor.right : True ## draw y axis right minor ticks #ytick.alignment : center_baseline ## alignment of yticks +#ytick.minor.default : 4 ## set default value for y axis minor ticks #### GRIDS #grid.color : b0b0b0 ## grid color From ba2c9c5d034184a094518be804a43478ccaf69dd Mon Sep 17 00:00:00 2001 From: Aditya Sinha A Date: Sat, 1 Jun 2019 00:31:46 +0530 Subject: [PATCH 2/7] Autominorticker feature added --- lib/matplotlib/rcsetup.py | 9 +++++++-- lib/matplotlib/ticker.py | 14 +++++++++++--- matplotlibrc.template | 4 ++-- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/lib/matplotlib/rcsetup.py b/lib/matplotlib/rcsetup.py index 97e15c101d45..7864c6417353 100644 --- a/lib/matplotlib/rcsetup.py +++ b/lib/matplotlib/rcsetup.py @@ -233,6 +233,11 @@ def validate_int_or_None(s): return int(s) except ValueError: raise ValueError('Could not convert "%s" to int' % s) + +def validate_int_or_auto(s): + if s == 'auto': + return s + return validate_int(s) def validate_fonttype(s): @@ -1310,7 +1315,7 @@ def _validate_linestyle(ls): 'xtick.minor.bottom': [True, validate_bool], # draw x axis bottom minor ticks 'xtick.major.top': [True, validate_bool], # draw x axis top major ticks 'xtick.major.bottom': [True, validate_bool], # draw x axis bottom major ticks - 'xtick.minor.default': [4,validate_int], #set default value for x axis minor ticks + 'xtick.minor.ndivs': ['auto', validate_int_or_auto], #set ndivs value for x axis minor ticks # fontsize of the xtick labels 'xtick.labelsize': ['medium', validate_fontsize], @@ -1333,7 +1338,7 @@ def _validate_linestyle(ls): 'ytick.minor.right': [True, validate_bool], # draw y axis right minor ticks 'ytick.major.left': [True, validate_bool], # draw y axis left major ticks 'ytick.major.right': [True, validate_bool], # draw y axis right major ticks - 'ytick.minor.default': [4,validate_int], #set default value for y axis minor ticks + 'ytick.minor.ndivs': ['auto', validate_int_or_auto], #set ndivs value for y axis minor ticks # fontsize of the ytick labels 'ytick.labelsize': ['medium', validate_fontsize], diff --git a/lib/matplotlib/ticker.py b/lib/matplotlib/ticker.py index 542a22adfcdd..d8d9f4680732 100644 --- a/lib/matplotlib/ticker.py +++ b/lib/matplotlib/ticker.py @@ -2634,7 +2634,15 @@ def __init__(self, n=None): If *n* is omitted or None, it will be set to 5 or 4. """ - self.ndivs = n + if n == None: + if self.axis.__name__ == 'x': + self.ndivs = rcParams['xtick.minor.ndivs'] + elif self.axis.__name__ == 'y': + self.ndivs = rcParams['ytick.minor.ndivs'] + elif n == 'auto': + self.ndivs = None + else: + self.ndivs = n def __call__(self): 'Return the locations of the ticks' @@ -2658,9 +2666,9 @@ def __call__(self): majorstep_no_exponent = 10 ** (np.log10(majorstep) % 1) if np.isclose(majorstep_no_exponent, [1.0, 2.5, 5.0, 10.0]).any(): - ndivs = rcParams['xtick.minor.default'] + 1 + ndivs = 5 else: - ndivs = rcParams['xtick.minor.default'] + ndivs = 4 else: ndivs = self.ndivs diff --git a/matplotlibrc.template b/matplotlibrc.template index fd1b10cc51ef..a5dd93176ce6 100644 --- a/matplotlibrc.template +++ b/matplotlibrc.template @@ -377,7 +377,7 @@ #xtick.minor.top : True ## draw x axis top minor ticks #xtick.minor.bottom : True ## draw x axis bottom minor ticks #xtick.alignment : center ## alignment of xticks -#xtick.minor.default : 4 ## set default value for x axis minor ticks +#xtick.minor.ndivs : auto ## set ndivs value for x axis minor ticks #ytick.left : True ## draw ticks on the left side #ytick.right : False ## draw ticks on the right side @@ -398,7 +398,7 @@ #ytick.minor.left : True ## draw y axis left minor ticks #ytick.minor.right : True ## draw y axis right minor ticks #ytick.alignment : center_baseline ## alignment of yticks -#ytick.minor.default : 4 ## set default value for y axis minor ticks +#ytick.minor.ndivs : auto ## set ndivs value for y axis minor ticks #### GRIDS #grid.color : b0b0b0 ## grid color From 428eb8960a477b57e3bdac3092f13e1e806f3d8c Mon Sep 17 00:00:00 2001 From: Aditya Sinha A Date: Sat, 1 Jun 2019 01:21:03 +0530 Subject: [PATCH 3/7] Autominorticker feature added --- lib/matplotlib/ticker.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/ticker.py b/lib/matplotlib/ticker.py index d8d9f4680732..cb06db17d53d 100644 --- a/lib/matplotlib/ticker.py +++ b/lib/matplotlib/ticker.py @@ -2635,9 +2635,9 @@ def __init__(self, n=None): If *n* is omitted or None, it will be set to 5 or 4. """ if n == None: - if self.axis.__name__ == 'x': + if Locator.axis.__name__ == 'xaxis': self.ndivs = rcParams['xtick.minor.ndivs'] - elif self.axis.__name__ == 'y': + elif Locator.axis.__name__ == 'yaxis': self.ndivs = rcParams['ytick.minor.ndivs'] elif n == 'auto': self.ndivs = None From a14d680421ed73fe931ae6efd956bef10dd4bb6f Mon Sep 17 00:00:00 2001 From: Trojan2498 Date: Wed, 5 Jun 2019 14:06:41 +0530 Subject: [PATCH 4/7] added auto feature to ndivs for both the axes --- lib/matplotlib/ticker.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/matplotlib/ticker.py b/lib/matplotlib/ticker.py index cb06db17d53d..9e2c5e93c2c5 100644 --- a/lib/matplotlib/ticker.py +++ b/lib/matplotlib/ticker.py @@ -2634,18 +2634,22 @@ def __init__(self, n=None): If *n* is omitted or None, it will be set to 5 or 4. """ + #print(self.ndivs) if n == None: - if Locator.axis.__name__ == 'xaxis': - self.ndivs = rcParams['xtick.minor.ndivs'] - elif Locator.axis.__name__ == 'yaxis': - self.ndivs = rcParams['ytick.minor.ndivs'] - elif n == 'auto': self.ndivs = None + elif n == 'auto': + self.ndivs = 'auto' else: self.ndivs = n def __call__(self): 'Return the locations of the ticks' + if self.ndivs is None: + if self.axis.__name__ == 'xaxis': + self.ndivs = rcParams['xtick.minor.ndivs'] + elif self.axis.__name__ == 'yaxis': + self.ndivs = rcParams['ytick.minor.ndivs'] + if self.axis.get_scale() == 'log': cbook._warn_external('AutoMinorLocator does not work with ' 'logarithmic scale') @@ -2661,7 +2665,7 @@ def __call__(self): # no ticks at all. return [] - if self.ndivs is None: + if self.ndivs == 'auto': majorstep_no_exponent = 10 ** (np.log10(majorstep) % 1) From 9078458fb3ef9ed0fbcc46cbfc3e9f90873a75a7 Mon Sep 17 00:00:00 2001 From: Trojan2498 Date: Wed, 5 Jun 2019 14:52:44 +0530 Subject: [PATCH 5/7] travis changes --- lib/matplotlib/rcsetup.py | 11 ++++++----- lib/matplotlib/ticker.py | 5 ++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/matplotlib/rcsetup.py b/lib/matplotlib/rcsetup.py index 7864c6417353..cba6b2c8d17f 100644 --- a/lib/matplotlib/rcsetup.py +++ b/lib/matplotlib/rcsetup.py @@ -233,7 +233,8 @@ def validate_int_or_None(s): return int(s) except ValueError: raise ValueError('Could not convert "%s" to int' % s) - + + def validate_int_or_auto(s): if s == 'auto': return s @@ -1315,11 +1316,11 @@ def _validate_linestyle(ls): 'xtick.minor.bottom': [True, validate_bool], # draw x axis bottom minor ticks 'xtick.major.top': [True, validate_bool], # draw x axis top major ticks 'xtick.major.bottom': [True, validate_bool], # draw x axis bottom major ticks - 'xtick.minor.ndivs': ['auto', validate_int_or_auto], #set ndivs value for x axis minor ticks + 'xtick.minor.ndivs': ['auto', validate_int_or_auto], # set ndivs value for x axis minor ticks # fontsize of the xtick labels 'xtick.labelsize': ['medium', validate_fontsize], - 'xtick.direction': ['out', validate_string], # direction of xticks + 'xtick.direction': ['out', validate_string], # direction of xticks 'xtick.alignment': ["center", _validate_alignment], 'ytick.left': [True, validate_bool], # draw ticks on the left side @@ -1338,11 +1339,11 @@ def _validate_linestyle(ls): 'ytick.minor.right': [True, validate_bool], # draw y axis right minor ticks 'ytick.major.left': [True, validate_bool], # draw y axis left major ticks 'ytick.major.right': [True, validate_bool], # draw y axis right major ticks - 'ytick.minor.ndivs': ['auto', validate_int_or_auto], #set ndivs value for y axis minor ticks + 'ytick.minor.ndivs': ['auto', validate_int_or_auto], # set ndivs value for y axis minor ticks # fontsize of the ytick labels 'ytick.labelsize': ['medium', validate_fontsize], - 'ytick.direction': ['out', validate_string], # direction of yticks + 'ytick.direction': ['out', validate_string], # direction of yticks 'ytick.alignment': ["center_baseline", _validate_alignment], 'grid.color': ['#b0b0b0', validate_color], # grid color diff --git a/lib/matplotlib/ticker.py b/lib/matplotlib/ticker.py index 9e2c5e93c2c5..84f4a5f81d90 100644 --- a/lib/matplotlib/ticker.py +++ b/lib/matplotlib/ticker.py @@ -2634,8 +2634,7 @@ def __init__(self, n=None): If *n* is omitted or None, it will be set to 5 or 4. """ - #print(self.ndivs) - if n == None: + if n is None: self.ndivs = None elif n == 'auto': self.ndivs = 'auto' @@ -2649,7 +2648,7 @@ def __call__(self): self.ndivs = rcParams['xtick.minor.ndivs'] elif self.axis.__name__ == 'yaxis': self.ndivs = rcParams['ytick.minor.ndivs'] - + if self.axis.get_scale() == 'log': cbook._warn_external('AutoMinorLocator does not work with ' 'logarithmic scale') From 104dc4074c672a7ce5c3dc51e4c1ab8616c0e08a Mon Sep 17 00:00:00 2001 From: Trojan2498 Date: Wed, 5 Jun 2019 23:54:05 +0530 Subject: [PATCH 6/7] travis changes --- lib/matplotlib/rcsetup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/rcsetup.py b/lib/matplotlib/rcsetup.py index cba6b2c8d17f..a2c71ecdaad6 100644 --- a/lib/matplotlib/rcsetup.py +++ b/lib/matplotlib/rcsetup.py @@ -1316,7 +1316,7 @@ def _validate_linestyle(ls): 'xtick.minor.bottom': [True, validate_bool], # draw x axis bottom minor ticks 'xtick.major.top': [True, validate_bool], # draw x axis top major ticks 'xtick.major.bottom': [True, validate_bool], # draw x axis bottom major ticks - 'xtick.minor.ndivs': ['auto', validate_int_or_auto], # set ndivs value for x axis minor ticks + 'xtick.minor.ndivs': ['auto', validate_int_or_auto], # sets ndivs value for x axis minor ticks # fontsize of the xtick labels 'xtick.labelsize': ['medium', validate_fontsize], @@ -1339,7 +1339,7 @@ def _validate_linestyle(ls): 'ytick.minor.right': [True, validate_bool], # draw y axis right minor ticks 'ytick.major.left': [True, validate_bool], # draw y axis left major ticks 'ytick.major.right': [True, validate_bool], # draw y axis right major ticks - 'ytick.minor.ndivs': ['auto', validate_int_or_auto], # set ndivs value for y axis minor ticks + 'ytick.minor.ndivs': ['auto', validate_int_or_auto], # sets ndivs value for y axis minor ticks # fontsize of the ytick labels 'ytick.labelsize': ['medium', validate_fontsize], From b5038d5ca727a75c01e5ba92e10d196ee2840c7b Mon Sep 17 00:00:00 2001 From: Trojan2498 Date: Thu, 6 Jun 2019 07:17:50 +0530 Subject: [PATCH 7/7] ticker.py updated --- lib/matplotlib/ticker.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/matplotlib/ticker.py b/lib/matplotlib/ticker.py index 84f4a5f81d90..985933b79681 100644 --- a/lib/matplotlib/ticker.py +++ b/lib/matplotlib/ticker.py @@ -2634,12 +2634,7 @@ def __init__(self, n=None): If *n* is omitted or None, it will be set to 5 or 4. """ - if n is None: - self.ndivs = None - elif n == 'auto': - self.ndivs = 'auto' - else: - self.ndivs = n + self.ndivs = n def __call__(self): 'Return the locations of the ticks'