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

Function test_arrow_contains_point

lib/matplotlib/tests/test_path.py:155–189  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

153@image_comparison(['arrow_contains_point.png'], remove_text=True, style='mpl20',
154 tol=0 if platform.machine() == 'x86_64' else 0.027)
155def test_arrow_contains_point():
156 # fix bug (#8384)
157 fig, ax = plt.subplots()
158 ax.set_xlim(0, 2)
159 ax.set_ylim(0, 2)
160
161 # create an arrow with Curve style
162 arrow = patches.FancyArrowPatch((0.5, 0.25), (1.5, 0.75),
163 arrowstyle='->',
164 mutation_scale=40)
165 ax.add_patch(arrow)
166 # create an arrow with Bracket style
167 arrow1 = patches.FancyArrowPatch((0.5, 1), (1.5, 1.25),
168 arrowstyle=']-[',
169 mutation_scale=40)
170 ax.add_patch(arrow1)
171 # create an arrow with other arrow style
172 arrow2 = patches.FancyArrowPatch((0.5, 1.5), (1.5, 1.75),
173 arrowstyle='fancy',
174 fill=False,
175 mutation_scale=40)
176 ax.add_patch(arrow2)
177 patches_list = [arrow, arrow1, arrow2]
178
179 # generate some points
180 X, Y = np.meshgrid(np.arange(0, 2, 0.1),
181 np.arange(0, 2, 0.1))
182 for k, (x, y) in enumerate(zip(X.ravel(), Y.ravel())):
183 xdisp, ydisp = ax.transData.transform([x, y])
184 event = MouseEvent('button_press_event', fig.canvas, xdisp, ydisp)
185 for m, patch in enumerate(patches_list):
186 # set the points to red only if the arrow contains the point
187 inside, res = patch.contains(event)
188 if inside:
189 ax.scatter(x, y, s=5, c="r")
190
191
192@image_comparison(['path_clipping.svg'], remove_text=True, style='_classic_test')

Callers

nothing calls this directly

Calls 8

MouseEventClass · 0.90
add_patchMethod · 0.80
subplotsMethod · 0.45
set_xlimMethod · 0.45
set_ylimMethod · 0.45
transformMethod · 0.45
containsMethod · 0.45
scatterMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…