MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / test_clip_to_bbox

Function test_clip_to_bbox

lib/matplotlib/tests/test_patches.py:245–269  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

243
244@image_comparison(['clip_to_bbox.png'], style='mpl20')
245def test_clip_to_bbox():
246 fig, ax = plt.subplots()
247 ax.set_xlim([-18, 20])
248 ax.set_ylim([-150, 100])
249
250 path = mpath.Path.unit_regular_star(8).deepcopy()
251 path.vertices *= [10, 100]
252 path.vertices -= [5, 25]
253
254 path2 = mpath.Path.unit_circle().deepcopy()
255 path2.vertices *= [10, 100]
256 path2.vertices += [10, -25]
257
258 combined = mpath.Path.make_compound_path(path, path2)
259
260 patch = mpatches.PathPatch(
261 combined, alpha=0.5, facecolor='coral', edgecolor='none')
262 ax.add_patch(patch)
263
264 bbox = mtransforms.Bbox([[-12, -77.5], [50, -110]])
265 result_path = combined.clip_to_bbox(bbox)
266 result_patch = mpatches.PathPatch(
267 result_path, alpha=0.5, facecolor='green', lw=4, edgecolor='black')
268
269 ax.add_patch(result_patch)
270
271
272@image_comparison(['patch_alpha_coloring'], remove_text=True, style='_classic_test')

Callers

nothing calls this directly

Calls 9

deepcopyMethod · 0.80
unit_regular_starMethod · 0.80
unit_circleMethod · 0.80
make_compound_pathMethod · 0.80
add_patchMethod · 0.80
clip_to_bboxMethod · 0.80
subplotsMethod · 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…