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

Skip to content

Commit 291091c

Browse files
authored
Merge pull request #8381 from efiring/fix_log_minor_ticks
LogLocator: fix problems with minor ticks. Closes #8111.
2 parents 4d4f8d3 + 54d6f08 commit 291091c

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

lib/matplotlib/ticker.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1970,8 +1970,6 @@ def tick_values(self, vmin, vmax):
19701970
return np.array([]) # no minor or major ticks
19711971
else:
19721972
subs = np.array([1.0]) # major ticks
1973-
elif numdec > 5 and b >= 6:
1974-
subs = np.arange(_first, b, 2.0)
19751973
else:
19761974
subs = np.arange(_first, b)
19771975
else:
@@ -1987,17 +1985,25 @@ def tick_values(self, vmin, vmax):
19871985
while numdec // stride + 1 > numticks:
19881986
stride += 1
19891987

1988+
# Does subs include anything other than 1?
1989+
have_subs = len(subs) > 1 or (len(subs == 1) and subs[0] != 1.0)
1990+
19901991
decades = np.arange(math.floor(vmin) - stride,
19911992
math.ceil(vmax) + 2 * stride, stride)
1993+
19921994
if hasattr(self, '_transform'):
19931995
ticklocs = self._transform.inverted().transform(decades)
1994-
if len(subs) > 1 or (len(subs == 1) and subs[0] != 1.0):
1995-
ticklocs = np.ravel(np.outer(subs, ticklocs))
1996+
if have_subs:
1997+
if stride == 1:
1998+
ticklocs = np.ravel(np.outer(subs, ticklocs))
1999+
else:
2000+
ticklocs = []
19962001
else:
1997-
if len(subs) > 1 or (len(subs == 1) and subs[0] != 1.0):
2002+
if have_subs:
19982003
ticklocs = []
1999-
for decadeStart in b ** decades:
2000-
ticklocs.extend(subs * decadeStart)
2004+
if stride == 1:
2005+
for decadeStart in b ** decades:
2006+
ticklocs.extend(subs * decadeStart)
20012007
else:
20022008
ticklocs = b ** decades
20032009

0 commit comments

Comments
 (0)