Skip to content

Commit 630494c

Browse files
committed
add test for fancyarrowpatch set_data
1 parent bbe2c90 commit 630494c

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

lib/matplotlib/tests/test_patches.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,37 @@ def test_fancyarrow_units():
522522
dtime = datetime(2000, 1, 1)
523523
fig, ax = plt.subplots()
524524
arrow = FancyArrowPatch((0, dtime), (0.01, dtime))
525-
ax.add_patch(arrow)
525+
526+
527+
def test_fancyarrow_setdata():
528+
fig, ax = plt.subplots()
529+
arrow = ax.arrow(0, 0, 10, 10, head_length=5, head_width=1, width=.5)
530+
expected1 = np.array(
531+
[[13.54, 13.54],
532+
[10.35, 9.65],
533+
[10.18, 9.82],
534+
[0.18, -0.18],
535+
[-0.18, 0.18],
536+
[9.82, 10.18],
537+
[9.65, 10.35],
538+
[13.54, 13.54]]
539+
)
540+
assert np.allclose(expected1, np.round(arrow.verts, 2))
541+
542+
expected2 = np.array(
543+
[[16.71, 16.71],
544+
[16.71, 15.29],
545+
[16.71, 15.29],
546+
[1.71, 0.29],
547+
[0.29, 1.71],
548+
[15.29, 16.71],
549+
[15.29, 16.71],
550+
[16.71, 16.71]]
551+
)
552+
arrow.set_data(
553+
x=1, y=1, dx=15, dy=15, width=2, head_width=2, head_length=1
554+
)
555+
assert np.allclose(expected2, np.round(arrow.verts, 2))
526556

527557

528558
@image_comparison(["large_arc.svg"], style="mpl20")

0 commit comments

Comments
 (0)