diff --git a/lib/matplotlib/tests/baseline_images/test_widgets/check_bunch_of_radio_buttons.png b/lib/matplotlib/tests/baseline_images/test_widgets/check_bunch_of_radio_buttons.png new file mode 100644 index 000000000000..e071860dfde6 Binary files /dev/null and b/lib/matplotlib/tests/baseline_images/test_widgets/check_bunch_of_radio_buttons.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_widgets/check_radio_buttons.png b/lib/matplotlib/tests/baseline_images/test_widgets/check_radio_buttons.png index c1ed74347bfe..e96085d9bffd 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_widgets/check_radio_buttons.png and b/lib/matplotlib/tests/baseline_images/test_widgets/check_radio_buttons.png differ diff --git a/lib/matplotlib/tests/test_widgets.py b/lib/matplotlib/tests/test_widgets.py index afd50ef24e3c..6eecb4b0c540 100644 --- a/lib/matplotlib/tests/test_widgets.py +++ b/lib/matplotlib/tests/test_widgets.py @@ -90,8 +90,9 @@ def onselect(epress, erelease): if kwargs.get('drawtype', None) not in ['line', 'none']: assert_allclose(tool.geometry, - [[100., 100, 199, 199, 100], [100, 199, 199, 100, 100]], - err_msg=tool.geometry) + [[100., 100, 199, 199, 100], + [100, 199, 199, 100, 100]], + err_msg=tool.geometry) assert ax._got_onselect @@ -118,40 +119,41 @@ def onselect(epress, erelease): # drag the rectangle do_event(tool, 'press', xdata=10, ydata=10, button=1, - key=' ') + key=' ') + do_event(tool, 'onmove', xdata=30, ydata=30, button=1) do_event(tool, 'release', xdata=30, ydata=30, button=1) assert tool.extents == (120, 170, 120, 170) # create from center do_event(tool, 'on_key_press', xdata=100, ydata=100, button=1, - key='control') + key='control') do_event(tool, 'press', xdata=100, ydata=100, button=1) do_event(tool, 'onmove', xdata=125, ydata=125, button=1) do_event(tool, 'release', xdata=125, ydata=125, button=1) do_event(tool, 'on_key_release', xdata=100, ydata=100, button=1, - key='control') + key='control') assert tool.extents == (75, 125, 75, 125) # create a square do_event(tool, 'on_key_press', xdata=10, ydata=10, button=1, - key='shift') + key='shift') do_event(tool, 'press', xdata=10, ydata=10, button=1) do_event(tool, 'onmove', xdata=35, ydata=30, button=1) do_event(tool, 'release', xdata=35, ydata=30, button=1) do_event(tool, 'on_key_release', xdata=10, ydata=10, button=1, - key='shift') + key='shift') extents = [int(e) for e in tool.extents] assert extents == [10, 35, 10, 34] # create a square from center do_event(tool, 'on_key_press', xdata=100, ydata=100, button=1, - key='ctrl+shift') + key='ctrl+shift') do_event(tool, 'press', xdata=100, ydata=100, button=1) do_event(tool, 'onmove', xdata=125, ydata=130, button=1) do_event(tool, 'release', xdata=125, ydata=130, button=1) do_event(tool, 'on_key_release', xdata=100, ydata=100, button=1, - key='ctrl+shift') + key='ctrl+shift') extents = [int(e) for e in tool.extents] assert extents == [70, 129, 70, 130] @@ -261,7 +263,7 @@ def test_CheckButtons(): @image_comparison(baseline_images=['check_radio_buttons'], extensions=['png'], - style='default') + style='mpl20', remove_text=True) def test_check_radio_buttons_image(): get_ax() plt.subplots_adjust(left=0.3) @@ -272,6 +274,15 @@ def test_check_radio_buttons_image(): (False, True, True)) +@image_comparison(baseline_images=['check_bunch_of_radio_buttons'], + style='mpl20', extensions=['png'], remove_text=True) +def test_check_bunch_of_radio_buttons(): + rax = plt.axes([0.05, 0.1, 0.15, 0.7]) + widgets.RadioButtons(rax, ('B1', 'B2', 'B3', 'B4', 'B5', 'B6', + 'B7', 'B8', 'B9', 'B10', 'B11', 'B12', + 'B13', 'B14', 'B15')) + + def test_slider_slidermin_slidermax_invalid(): fig, ax = plt.subplots() # test min/max with floats diff --git a/lib/matplotlib/widgets.py b/lib/matplotlib/widgets.py index ca6f544ada4d..c785a61eb4b5 100644 --- a/lib/matplotlib/widgets.py +++ b/lib/matplotlib/widgets.py @@ -986,6 +986,13 @@ def __init__(self, ax, labels, active=0, activecolor='blue'): cnt = 0 axcolor = ax.get_facecolor() + # scale the radius of the circle with the spacing between each one + circle_radius = (dy / 2) - 0.01 + + # defaul to hard-coded value if the radius becomes too large + if(circle_radius > 0.05): + circle_radius = 0.05 + self.labels = [] self.circles = [] for y, label in zip(ys, labels): @@ -999,7 +1006,7 @@ def __init__(self, ax, labels, active=0, activecolor='blue'): else: facecolor = axcolor - p = Circle(xy=(0.15, y), radius=0.05, edgecolor='black', + p = Circle(xy=(0.15, y), radius=circle_radius, edgecolor='black', facecolor=facecolor, transform=ax.transAxes) self.labels.append(t)