Skip to content

Commit 1790c88

Browse files
authored
Merge pull request #30253 from QuLogic/auto-backport-of-pr-30243-on-v3.10.x
Backport PR #30243 on branch v3.10.x (Fix FancyArrow rendering for zero-length arrows)
2 parents 5c13534 + b1d31f1 commit 1790c88

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/matplotlib/patches.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1515,7 +1515,7 @@ def _make_verts(self):
15151515
length = distance
15161516
else:
15171517
length = distance + head_length
1518-
if not length:
1518+
if np.size(length) == 0:
15191519
self.verts = np.empty([0, 2]) # display nothing if empty
15201520
else:
15211521
# start by drawing horizontal arrow, point at (0, 0)

lib/matplotlib/tests/test_patches.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -999,3 +999,9 @@ def test_set_and_get_hatch_linewidth(fig_test, fig_ref):
999999

10001000
assert ax_ref.patches[0].get_hatch_linewidth() == lw
10011001
assert ax_test.patches[0].get_hatch_linewidth() == lw
1002+
1003+
1004+
def test_empty_fancyarrow():
1005+
fig, ax = plt.subplots()
1006+
arrow = ax.arrow([], [], [], [])
1007+
assert arrow is not None

0 commit comments

Comments
 (0)