()
| 98 | |
| 99 | @image_comparison(["clip_path_clipping"], remove_text=True, style='_classic_test') |
| 100 | def 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() |
nothing calls this directly
no test coverage detected
searching dependent graphs…