()
| 309 | |
| 310 | |
| 311 | def test_picking(): |
| 312 | fig, ax = plt.subplots() |
| 313 | mouse_event = SimpleNamespace(x=fig.bbox.width // 2, |
| 314 | y=fig.bbox.height // 2 + 15) |
| 315 | |
| 316 | # Default pickradius is 5, so event should not pick this line. |
| 317 | l0, = ax.plot([0, 1], [0, 1], picker=True) |
| 318 | found, indices = l0.contains(mouse_event) |
| 319 | assert not found |
| 320 | |
| 321 | # But with a larger pickradius, this should be picked. |
| 322 | l1, = ax.plot([0, 1], [0, 1], picker=True, pickradius=20) |
| 323 | found, indices = l1.contains(mouse_event) |
| 324 | assert found |
| 325 | assert_array_equal(indices['ind'], [0]) |
| 326 | |
| 327 | # And if we modify the pickradius after creation, it should work as well. |
| 328 | l2, = ax.plot([0, 1], [0, 1], picker=True) |
| 329 | found, indices = l2.contains(mouse_event) |
| 330 | assert not found |
| 331 | l2.set_pickradius(20) |
| 332 | found, indices = l2.contains(mouse_event) |
| 333 | assert found |
| 334 | assert_array_equal(indices['ind'], [0]) |
| 335 | |
| 336 | |
| 337 | @check_figures_equal() |
nothing calls this directly
no test coverage detected
searching dependent graphs…