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

Skip to content

Commit b477cf6

Browse files
authored
Merge pull request #9519 from dstansby/patch-tests
Increase patch test coverage
2 parents 0aaf239 + 3e51711 commit b477cf6

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

lib/matplotlib/tests/test_arrow_patches.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,20 @@ def test_fancyarrow_dash():
119119
color='k')
120120
ax.add_patch(e)
121121
ax.add_patch(e2)
122+
123+
124+
@image_comparison(baseline_images=['arrow_styles'], extensions=['png'],
125+
style='mpl20', remove_text=True)
126+
def test_arrow_styles():
127+
styles = mpatches.ArrowStyle.get_styles()
128+
129+
n = len(styles)
130+
fig, ax = plt.subplots(figsize=(6, 10))
131+
ax.set_xlim(0, 1)
132+
ax.set_ylim(-1, n)
133+
134+
for i, stylename in enumerate(sorted(styles)):
135+
patch = mpatches.FancyArrowPatch((0.1, i), (0.8, i),
136+
arrowstyle=stylename,
137+
mutation_scale=25)
138+
ax.add_patch(patch)

lib/matplotlib/tests/test_patches.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ def test_multi_color_hatch():
335335

336336
for i in range(5):
337337
with mstyle.context({'hatch.color': 'C{}'.format(i)}):
338-
r = Rectangle((i-.8/2, 5), .8, 1, hatch='//', fc='none')
338+
r = Rectangle((i - .8 / 2, 5), .8, 1, hatch='//', fc='none')
339339
ax.add_patch(r)
340340

341341

@@ -350,3 +350,15 @@ def test_units_rectangle():
350350
ax.add_patch(p)
351351
ax.set_xlim([4*U.km, 7*U.km])
352352
ax.set_ylim([5*U.km, 9*U.km])
353+
354+
355+
@image_comparison(baseline_images=['connection_patch'], extensions=['png'],
356+
style='mpl20', remove_text=True)
357+
def test_connection_patch():
358+
fig, (ax1, ax2) = plt.subplots(1, 2)
359+
360+
con = mpatches.ConnectionPatch(xyA=(0.1, 0.1), xyB=(0.9, 0.9),
361+
coordsA='data', coordsB='data',
362+
axesA=ax2, axesB=ax1,
363+
arrowstyle="->")
364+
ax2.add_artist(con)

0 commit comments

Comments
 (0)