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 cefba05

Browse filesBrowse files
committed
FIX: always use at least 2 ticks and recompute
For extreme aspect-ratio plots the auto ntick logic would decide that no ticks will fit, leading to divide by 0 issue. - In ticker ensure there is always at least on bin - Axis do not cache the number of ticks so that if the on-screen aspect ratio changes the number of ticks will update correctly.
1 parent f257244 commit cefba05
Copy full SHA for cefba05

File tree

Expand file treeCollapse file tree

2 files changed

+3
-3
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+3
-3
lines changed

‎lib/matplotlib/axis.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axis.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2004,7 +2004,7 @@ def get_tick_space(self):
20042004
# is no more than 3:1
20052005
size = tick.label1.get_size() * 3
20062006
size *= np.cos(np.deg2rad(tick.label1.get_rotation()))
2007-
self._tick_space = np.floor(length / size)
2007+
return np.floor(length / size)
20082008
return self._tick_space
20092009

20102010

@@ -2346,5 +2346,5 @@ def get_tick_space(self):
23462346
# Having a spacing of at least 2 just looks good.
23472347
size = tick.label1.get_size() * 2.0
23482348
size *= np.cos(np.deg2rad(tick.label1.get_rotation()))
2349-
self._tick_space = np.floor(length / size)
2349+
return np.floor(length / size)
23502350
return self._tick_space

‎lib/matplotlib/ticker.py

Copy file name to clipboardExpand all lines: lib/matplotlib/ticker.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1434,7 +1434,7 @@ def set_params(self, **kwargs):
14341434
def bin_boundaries(self, vmin, vmax):
14351435
nbins = self._nbins
14361436
if nbins == 'auto':
1437-
nbins = min(self.axis.get_tick_space(), 9)
1437+
nbins = max(min(self.axis.get_tick_space(), 9), 1)
14381438
scale, offset = scale_range(vmin, vmax, nbins)
14391439
if self._integer:
14401440
scale = max(1, scale)

0 commit comments

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