Skip to content

Commit 6b7f539

Browse files
committed
Make sure bounding box is drawn when setting .verts
1 parent 8451e27 commit 6b7f539

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

lib/matplotlib/tests/test_widgets.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,17 +1332,20 @@ def test_polygon_selector_redraw(ax, draw_bounding_box):
13321332
assert tool.verts == verts[0:2]
13331333

13341334

1335-
@check_figures_equal()
1336-
def test_polygon_selector_verts_setter(fig_test, fig_ref):
1335+
@pytest.mark.parametrize('draw_bounding_box', [False, True])
1336+
@check_figures_equal(extensions=['png'])
1337+
def test_polygon_selector_verts_setter(fig_test, fig_ref, draw_bounding_box):
13371338
verts = [(0.1, 0.4), (0.5, 0.9), (0.3, 0.2)]
13381339
ax_test = fig_test.add_subplot()
13391340

1340-
tool_test = widgets.PolygonSelector(ax_test, onselect=noop)
1341+
tool_test = widgets.PolygonSelector(
1342+
ax_test, onselect=noop, draw_bounding_box=draw_bounding_box)
13411343
tool_test.verts = verts
13421344
assert tool_test.verts == verts
13431345

13441346
ax_ref = fig_ref.add_subplot()
1345-
tool_ref = widgets.PolygonSelector(ax_ref, onselect=noop)
1347+
tool_ref = widgets.PolygonSelector(
1348+
ax_ref, onselect=noop, draw_bounding_box=draw_bounding_box)
13461349
event_sequence = (polygon_place_vertex(*verts[0]) +
13471350
polygon_place_vertex(*verts[1]) +
13481351
polygon_place_vertex(*verts[2]) +

lib/matplotlib/widgets.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3928,6 +3928,8 @@ def verts(self, xys):
39283928
self._ys.append(self._ys[0])
39293929
self._selection_completed = True
39303930
self.set_visible(True)
3931+
if self._draw_box and self._box is None:
3932+
self._add_box()
39313933
self._draw_polygon()
39323934

39333935

0 commit comments

Comments
 (0)