From b1d31f129672713422f9c7c719f64389917dd30e Mon Sep 17 00:00:00 2001 From: N R Navaneet <156576749+nrnavaneet@users.noreply.github.com> Date: Thu, 3 Jul 2025 10:44:51 +0530 Subject: [PATCH] Backport PR #30243: Fix FancyArrow rendering for zero-length arrows --- lib/matplotlib/patches.py | 2 +- lib/matplotlib/tests/test_patches.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/patches.py b/lib/matplotlib/patches.py index 736b1e77e1ac..96b9c4f11066 100644 --- a/lib/matplotlib/patches.py +++ b/lib/matplotlib/patches.py @@ -1515,7 +1515,7 @@ def _make_verts(self): length = distance else: length = distance + head_length - if not length: + if np.size(length) == 0: self.verts = np.empty([0, 2]) # display nothing if empty else: # start by drawing horizontal arrow, point at (0, 0) diff --git a/lib/matplotlib/tests/test_patches.py b/lib/matplotlib/tests/test_patches.py index d98998ef179a..98e45dbad9e0 100644 --- a/lib/matplotlib/tests/test_patches.py +++ b/lib/matplotlib/tests/test_patches.py @@ -999,3 +999,9 @@ def test_set_and_get_hatch_linewidth(fig_test, fig_ref): assert ax_ref.patches[0].get_hatch_linewidth() == lw assert ax_test.patches[0].get_hatch_linewidth() == lw + + +def test_empty_fancyarrow(): + fig, ax = plt.subplots() + arrow = ax.arrow([], [], [], []) + assert arrow is not None