Skip to content

Commit 5428f6c

Browse files
committed
Fixed bug-4429 and created image comparison test for bug-4429
1 parent 24d530e commit 5428f6c

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

lib/matplotlib/tests/test_widgets.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,11 @@ def test_check_radio_buttons_image():
271271
widgets.CheckButtons(rax2, ('Check 1', 'Check 2', 'Check 3'),
272272
(False, True, True))
273273

274+
@image_comparison(baseline_images=['check_bunch_of_radio_buttons'], extensions=['png'],
275+
style='default')
276+
def test_check_bunch_of_radio_buttons():
277+
rax = plt.axes([0.05, 0.1, 0.15, 0.7])
278+
widgets.RadioButtons(rax, ('B1', 'B2', 'B3', 'B4', 'B5','B6', 'B7', 'B8', 'B9', 'B10', 'B11', 'B12', 'B13', 'B14', 'B15'))
274279

275280
def test_slider_slidermin_slidermax_invalid():
276281
fig, ax = plt.subplots()

lib/matplotlib/widgets.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -986,6 +986,13 @@ def __init__(self, ax, labels, active=0, activecolor='blue'):
986986
cnt = 0
987987
axcolor = ax.get_facecolor()
988988

989+
# scale the radius of the circle with the spacing between each one
990+
circle_radius = (dy / 2) - 0.01
991+
992+
# default to hardcoded value if the radius becomes too large
993+
if(circle_radius > 0.05):
994+
circle_radius = 0.05
995+
989996
self.labels = []
990997
self.circles = []
991998
for y, label in zip(ys, labels):
@@ -999,7 +1006,7 @@ def __init__(self, ax, labels, active=0, activecolor='blue'):
9991006
else:
10001007
facecolor = axcolor
10011008

1002-
p = Circle(xy=(0.15, y), radius=0.05, edgecolor='black',
1009+
p = Circle(xy=(0.15, y), radius=circle_radius, edgecolor='black',
10031010
facecolor=facecolor, transform=ax.transAxes)
10041011

10051012
self.labels.append(t)

0 commit comments

Comments
 (0)