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

Function test_rectangle_handles

lib/matplotlib/tests/test_widgets.py:558–586  ·  view source on GitHub ↗
(ax)

Source from the content-addressed store, hash-verified

556
557
558def test_rectangle_handles(ax):
559 tool = widgets.RectangleSelector(ax, grab_range=10, interactive=True,
560 handle_props={'markerfacecolor': 'r',
561 'markeredgecolor': 'b'})
562 tool.extents = (100, 150, 100, 150)
563
564 assert_allclose(tool.corners, ((100, 150, 150, 100), (100, 100, 150, 150)))
565 assert tool.extents == (100, 150, 100, 150)
566 assert_allclose(tool.edge_centers,
567 ((100, 125.0, 150, 125.0), (125.0, 100, 125.0, 150)))
568 assert tool.extents == (100, 150, 100, 150)
569
570 # grab a corner and move it
571 click_and_drag(tool, start=(100, 100), end=(120, 120))
572 assert tool.extents == (120, 150, 120, 150)
573
574 # grab the center and move it
575 click_and_drag(tool, start=(132, 132), end=(120, 120))
576 assert tool.extents == (108, 138, 108, 138)
577
578 # create a new rectangle
579 click_and_drag(tool, start=(10, 10), end=(100, 100))
580 assert tool.extents == (10, 100, 10, 100)
581
582 # Check that marker_props worked.
583 assert mcolors.same_color(
584 tool._corner_handles.artists[0].get_markerfacecolor(), 'r')
585 assert mcolors.same_color(
586 tool._corner_handles.artists[0].get_markeredgecolor(), 'b')
587
588
589@pytest.mark.parametrize('interactive', [True, False])

Callers

nothing calls this directly

Calls 3

click_and_dragFunction · 0.90
get_markerfacecolorMethod · 0.80
get_markeredgecolorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…