Skip to content

Commit 54d6f08

Browse files
committed
LogLocator: fix problems with minor ticks. Closes #8111.
The subsetting of minor ticks that was introduced in v2.0 made it hard to know what number a given unlabeled minor tick represents, so we have decided that minor log ticks should be all integer multiples of the decade (except the decade itself). When major ticks skip decades, then minor ticks are omitted entirely.
1 parent 36ec04f commit 54d6f08

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

lib/matplotlib/ticker.py

+13-7
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)