Skip to content

Commit 70d5ad4

Browse files
authored
Fix FancyArrow rendering for zero-length arrows (matplotlib#30243)
* WIP: changed FancyArrow empty logic * Update test_patches.py * Update test_patches.py * Fix crash when drawing FancyArrow with zero length * Update patches.py * Delete .python-version
1 parent 40516e8 commit 70d5ad4

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
@@ -1538,7 +1538,7 @@ def _make_verts(self):
15381538
length = distance
15391539
else:
15401540
length = distance + head_length
1541-
if not length:
1541+
if np.size(length) == 0:
15421542
self.verts = np.empty([0, 2]) # display nothing if empty
15431543
else:
15441544
# 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
@@ -1093,3 +1093,9 @@ def test_facecolor_none_edgecolor_force_edgecolor():
10931093
rcParams['patch.edgecolor'] = 'red'
10941094
rect = Rectangle((0, 0), 1, 1, facecolor="none")
10951095
assert mcolors.same_color(rect.get_edgecolor(), rcParams['patch.edgecolor'])
1096+
1097+
1098+
def test_empty_fancyarrow():
1099+
fig, ax = plt.subplots()
1100+
arrow = ax.arrow([], [], [], [])
1101+
assert arrow is not None

0 commit comments

Comments
 (0)