diff --git a/lib/matplotlib/patches.py b/lib/matplotlib/patches.py index ac86eebc9bc3..708afffd7f35 100644 --- a/lib/matplotlib/patches.py +++ b/lib/matplotlib/patches.py @@ -1269,7 +1269,7 @@ def __init__(self, x, y, dx, dy, width=0.001, length_includes_head=False, else: length = distance + head_length if not length: - verts = [] # display nothing if empty + verts = np.empty([0, 2]) # display nothing if empty else: # start by drawing horizontal arrow, point at (0,0) hw, hl, hs, lw = head_width, head_length, overhang, width diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index 45384d6b30fa..58e6e2126b06 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -379,6 +379,12 @@ def test_arrow_simple(): head_length=theta / 10) +def test_arrow_empty(): + _, ax = plt.subplots() + # Create an empty FancyArrow + ax.arrow(0, 0, 0, 0, head_length=0) + + def test_annotate_default_arrow(): # Check that we can make an annotation arrow with only default properties. fig, ax = plt.subplots()