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

Function test_preset_clip_paths

lib/matplotlib/tests/test_axes.py:9845–9878  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

9843@image_comparison(["preset_clip_paths.png"], remove_text=True, style="mpl20",
9844 tol=0.01 if sys.platform == 'darwin' else 0)
9845def test_preset_clip_paths():
9846 fig, ax = plt.subplots()
9847
9848 poly = mpl.patches.Polygon(
9849 [[1, 0], [0, 1], [-1, 0], [0, -1]], facecolor="#ddffdd",
9850 edgecolor="#00ff00", linewidth=2, alpha=0.5)
9851
9852 ax.add_patch(poly)
9853
9854 line = mpl.lines.Line2D((-1, 1), (0.5, 0.5), clip_on=True, clip_path=poly)
9855 line.set_path_effects([patheffects.withTickedStroke()])
9856 ax.add_artist(line)
9857
9858 line = mpl.lines.Line2D((-1, 1), (-0.5, -0.5), color='r', clip_on=True,
9859 clip_path=poly)
9860 ax.add_artist(line)
9861
9862 poly2 = mpl.patches.Polygon(
9863 [[-1, 1], [0, 1], [0, -0.25]], facecolor="#beefc0", alpha=0.3,
9864 edgecolor="#faded0", linewidth=2, clip_on=True, clip_path=poly)
9865 ax.add_artist(poly2)
9866
9867 # When text clipping works, the "Annotation" text should be clipped
9868 ax.annotate('Annotation', (-0.75, -0.75), xytext=(0.1, 0.75),
9869 arrowprops={'color': 'k'}, clip_on=True, clip_path=poly)
9870
9871 poly3 = mpl.patches.Polygon(
9872 [[0, 0], [0, 0.5], [0.5, 0.5], [0.5, 0]], facecolor="g", edgecolor="y",
9873 linewidth=2, alpha=0.3, clip_on=True, clip_path=poly)
9874
9875 fig.add_artist(poly3, clip=True)
9876
9877 ax.set_xlim(-1, 1)
9878 ax.set_ylim(-1, 1)
9879
9880
9881@mpl.style.context('default')

Callers

nothing calls this directly

Calls 7

add_patchMethod · 0.80
set_path_effectsMethod · 0.80
annotateMethod · 0.80
subplotsMethod · 0.45
add_artistMethod · 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…