Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b813160

Browse filesBrowse files
committed
generalize label location for all bases
1 parent 8683ef0 commit b813160
Copy full SHA for b813160

File tree

Expand file treeCollapse file tree

1 file changed

+8
-12
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+8
-12
lines changed

‎lib/matplotlib/ticker.py

Copy file name to clipboardExpand all lines: lib/matplotlib/ticker.py
+8-12Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1629,22 +1629,18 @@ def show_tick_label(self, ticklocs):
16291629
numdec = abs(vmax - vmin)
16301630

16311631
if numdec > 3:
1632+
# Label only bases
16321633
sublabel = set((1,))
1633-
elif numdec > 2:
1634-
sublabel = set((1, 3))
1635-
elif numdec > 1:
1636-
sublabel = set((1, 2, 5))
16371634
else:
1638-
sublabel = set((1, 2, 4, 7))
1635+
# Add labels between bases at log-spaced coefficients
1636+
c = np.logspace(0, 1, (4 - int(numdec)) + 1, base=b)
1637+
sublabel = set(np.round(c))
16391638

1640-
label = np.ones(ticklocs.size, dtype=np.bool)
1641-
for i, loc in enumerate(ticklocs):
1642-
exponent = math.floor(math.log(abs(loc)) / math.log(b))
1643-
coeff = loc / b ** nearest_long(exponent)
1644-
if nearest_long(coeff) not in sublabel:
1645-
label[i] = False
1639+
show_label = np.ones(ticklocs.size, dtype=np.bool)
1640+
exponents = np.floor(np.log(abs(ticklocs)) / np.log(b))
1641+
coeffs = np.round(ticklocs / b ** exponents)
16461642

1647-
return label
1643+
return [c in sublabel for c in coeffs]
16481644

16491645
def view_limits(self, vmin, vmax):
16501646
'Try to choose the view limits intelligently'

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.