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

Skip to content

Commit a14d680

Browse files
committed
added auto feature to ndivs for both the axes
1 parent 428eb89 commit a14d680

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

lib/matplotlib/ticker.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2634,18 +2634,22 @@ def __init__(self, n=None):
26342634
26352635
If *n* is omitted or None, it will be set to 5 or 4.
26362636
"""
2637+
#print(self.ndivs)
26372638
if n == None:
2638-
if Locator.axis.__name__ == 'xaxis':
2639-
self.ndivs = rcParams['xtick.minor.ndivs']
2640-
elif Locator.axis.__name__ == 'yaxis':
2641-
self.ndivs = rcParams['ytick.minor.ndivs']
2642-
elif n == 'auto':
26432639
self.ndivs = None
2640+
elif n == 'auto':
2641+
self.ndivs = 'auto'
26442642
else:
26452643
self.ndivs = n
26462644

26472645
def __call__(self):
26482646
'Return the locations of the ticks'
2647+
if self.ndivs is None:
2648+
if self.axis.__name__ == 'xaxis':
2649+
self.ndivs = rcParams['xtick.minor.ndivs']
2650+
elif self.axis.__name__ == 'yaxis':
2651+
self.ndivs = rcParams['ytick.minor.ndivs']
2652+
26492653
if self.axis.get_scale() == 'log':
26502654
cbook._warn_external('AutoMinorLocator does not work with '
26512655
'logarithmic scale')
@@ -2661,7 +2665,7 @@ def __call__(self):
26612665
# no ticks at all.
26622666
return []
26632667

2664-
if self.ndivs is None:
2668+
if self.ndivs == 'auto':
26652669

26662670
majorstep_no_exponent = 10 ** (np.log10(majorstep) % 1)
26672671

0 commit comments

Comments
 (0)