Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8beb59a

Browse files
committed
Merge pull request #7861 from naoyak/widget-edges
Make radio and check buttons visible
1 parent 34ba25d commit 8beb59a

File tree

3 files changed

+35
-10
lines changed

3 files changed

+35
-10
lines changed

lib/matplotlib/tests/test_widgets.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import matplotlib.widgets as widgets
1111
import matplotlib.pyplot as plt
12-
from matplotlib.testing.decorators import cleanup
12+
from matplotlib.testing.decorators import cleanup, image_comparison
1313

1414
from numpy.testing import assert_allclose
1515

@@ -257,3 +257,29 @@ def test_lasso_selector():
257257
check_lasso_selector()
258258
check_lasso_selector(useblit=False, lineprops=dict(color='red'))
259259
check_lasso_selector(useblit=True, button=1)
260+
261+
262+
@cleanup
263+
def test_CheckButtons():
264+
ax = get_ax()
265+
check = widgets.CheckButtons(ax, ('a', 'b', 'c'), (True, False, True))
266+
assert check.get_status() == [True, False, True]
267+
check.set_active(0)
268+
assert check.get_status() == [False, False, True]
269+
270+
def clicked_function():
271+
pass
272+
cid = check.on_clicked(clicked_function)
273+
check.disconnect(cid)
274+
275+
276+
@image_comparison(baseline_images=['check_radio_buttons'], extensions=['png'],
277+
style='default')
278+
def test_check_radio_buttons_image():
279+
get_ax()
280+
plt.subplots_adjust(left=0.3)
281+
rax1 = plt.axes([0.05, 0.7, 0.15, 0.15])
282+
rax2 = plt.axes([0.05, 0.2, 0.15, 0.15])
283+
widgets.RadioButtons(rax1, ('Radio 1', 'Radio 2', 'Radio 3'))
284+
widgets.CheckButtons(rax2, ('Check 1', 'Check 2', 'Check 3'),
285+
(False, True, True))

lib/matplotlib/widgets.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -539,9 +539,8 @@ def __init__(self, ax, labels, actives):
539539
w, h = dy / 2., dy / 2.
540540
x, y = 0.05, y - h / 2.
541541

542-
p = Rectangle(xy=(x, y), width=w, height=h,
543-
facecolor=axcolor,
544-
transform=ax.transAxes)
542+
p = Rectangle(xy=(x, y), width=w, height=h, edgecolor='black',
543+
facecolor=axcolor, transform=ax.transAxes)
545544

546545
l1 = Line2D([x, x + w], [y + h, y], **lineparams)
547546
l2 = Line2D([x, x + w], [y, y + h], **lineparams)
@@ -686,8 +685,8 @@ def __init__(self, ax, labels, active=0, activecolor='blue'):
686685
else:
687686
facecolor = axcolor
688687

689-
p = Circle(xy=(0.15, y), radius=0.05, facecolor=facecolor,
690-
transform=ax.transAxes)
688+
p = Circle(xy=(0.15, y), radius=0.05, edgecolor='black',
689+
facecolor=facecolor, transform=ax.transAxes)
691690

692691
self.labels.append(t)
693692
self.circles.append(p)
@@ -1758,8 +1757,8 @@ def __init__(self, ax, onselect, drawtype='box',
17581757
alpha=0.2, fill=True)
17591758
rectprops['animated'] = self.useblit
17601759
self.rectprops = rectprops
1761-
self.to_draw = self._shape_klass((0, 0),
1762-
0, 1, visible=False, **self.rectprops)
1760+
self.to_draw = self._shape_klass((0, 0), 0, 1, visible=False,
1761+
**self.rectprops)
17631762
self.ax.add_patch(self.to_draw)
17641763
if drawtype == 'line':
17651764
if lineprops is None:
@@ -2170,9 +2169,9 @@ def onselect(verts):
21702169
"""
21712170

21722171
def __init__(self, ax, onselect=None, useblit=True, lineprops=None,
2173-
button=None):
2172+
button=None):
21742173
_SelectorWidget.__init__(self, ax, onselect, useblit=useblit,
2175-
button=button)
2174+
button=button)
21762175

21772176
self.verts = None
21782177

0 commit comments

Comments
 (0)