Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit adda7cc

Browse files
authored
Merge pull request #13652 from nathan78906/issue-11217
Fix empty FancyArrow crash
2 parents 0499a18 + 606e8e2 commit adda7cc

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
@@ -1269,7 +1269,7 @@ def __init__(self, x, y, dx, dy, width=0.001, length_includes_head=False,
12691269
else:
12701270
length = distance + head_length
12711271
if not length:
1272-
verts = [] # display nothing if empty
1272+
verts = np.empty([0, 2]) # display nothing if empty
12731273
else:
12741274
# start by drawing horizontal arrow, point at (0,0)
12751275
hw, hl, hs, lw = head_width, head_length, overhang, width

lib/matplotlib/tests/test_axes.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,12 @@ def test_arrow_simple():
379379
head_length=theta / 10)
380380

381381

382+
def test_arrow_empty():
383+
_, ax = plt.subplots()
384+
# Create an empty FancyArrow
385+
ax.arrow(0, 0, 0, 0, head_length=0)
386+
387+
382388
def test_annotate_default_arrow():
383389
# Check that we can make an annotation arrow with only default properties.
384390
fig, ax = plt.subplots()

0 commit comments

Comments
 (0)