MCPcopy
hub / github.com/matplotlib/matplotlib / test_clipping

Function test_clipping

lib/matplotlib/tests/test_artist.py:100–124  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

98
99@image_comparison(["clip_path_clipping"], remove_text=True, style='_classic_test')
100def test_clipping():
101 exterior = mpath.Path.unit_rectangle().deepcopy()
102 exterior.vertices *= 4
103 exterior.vertices -= 2
104 interior = mpath.Path.unit_circle().deepcopy()
105 interior.vertices = interior.vertices[::-1]
106 clip_path = mpath.Path.make_compound_path(exterior, interior)
107
108 star = mpath.Path.unit_regular_star(6).deepcopy()
109 star.vertices *= 2.6
110
111 fig, (ax1, ax2) = plt.subplots(1, 2, sharex=True, sharey=True)
112
113 col = mcollections.PathCollection([star], lw=5, edgecolor='blue',
114 facecolor='red', alpha=0.7, hatch='*')
115 col.set_clip_path(clip_path, ax1.transData)
116 ax1.add_collection(col)
117
118 patch = mpatches.PathPatch(star, lw=5, edgecolor='blue', facecolor='red',
119 alpha=0.7, hatch='*')
120 patch.set_clip_path(clip_path, ax2.transData)
121 ax2.add_patch(patch)
122
123 ax1.set_xlim(-3, 3)
124 ax1.set_ylim(-3, 3)
125
126
127@check_figures_equal()

Callers

nothing calls this directly

Calls 11

deepcopyMethod · 0.80
unit_rectangleMethod · 0.80
unit_circleMethod · 0.80
make_compound_pathMethod · 0.80
unit_regular_starMethod · 0.80
add_collectionMethod · 0.80
add_patchMethod · 0.80
subplotsMethod · 0.45
set_clip_pathMethod · 0.45
set_xlimMethod · 0.45
set_ylimMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…