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 729d219

Browse filesBrowse files
dstansbyNelleV
authored andcommitted
Merge pull request #7959 from scopatz/size0tick
Allow zero sized ticks
1 parent 9b6f7c1 commit 729d219
Copy full SHA for 729d219

File tree

Expand file treeCollapse file tree

2 files changed

+18
-2
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+18
-2
lines changed

‎lib/matplotlib/axis.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axis.py
+8-2Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2021,7 +2021,10 @@ def get_tick_space(self):
20212021
# There is a heuristic here that the aspect ratio of tick text
20222022
# is no more than 3:1
20232023
size = tick.label1.get_size() * 3
2024-
return int(np.floor(length / size))
2024+
if size > 0:
2025+
return int(np.floor(length / size))
2026+
else:
2027+
return 2**31 - 1
20252028

20262029

20272030
class YAxis(Axis):
@@ -2354,4 +2357,7 @@ def get_tick_space(self):
23542357
tick = self._get_tick(True)
23552358
# Having a spacing of at least 2 just looks good.
23562359
size = tick.label1.get_size() * 2.0
2357-
return int(np.floor(length / size))
2360+
if size > 0:
2361+
return int(np.floor(length / size))
2362+
else:
2363+
return 2**31 - 1

‎lib/matplotlib/tests/test_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_axes.py
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2301,6 +2301,16 @@ def test_manage_xticks():
23012301
assert_array_equal(old_xlim, new_xlim)
23022302

23032303

2304+
@cleanup
2305+
def test_tick_space_size_0():
2306+
# allow font size to be zero, which affects ticks when there is
2307+
# no other text in the figure.
2308+
plt.plot([0, 1], [0, 1])
2309+
matplotlib.rcParams.update({'font.size': 0})
2310+
b = io.BytesIO()
2311+
plt.savefig(b, dpi=80, format='raw')
2312+
2313+
23042314
@image_comparison(baseline_images=['errorbar_basic', 'errorbar_mixed',
23052315
'errorbar_basic'])
23062316
def test_errorbar():

0 commit comments

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