Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix scaling of RadioButtons#10780

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View file
Open in desktop
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 21 additions & 10 deletionslib/matplotlib/tests/test_widgets.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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

Expand All@@ -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]

Expand DownExpand Up@@ -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)
Expand All@@ -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
Expand Down
9 changes: 8 additions & 1 deletionlib/matplotlib/widgets.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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):
Expand All@@ -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)
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp