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

Appearance settings

Commit 473409e

Browse filesBrowse files
authored
Merge pull request #9526 from matplotlib/auto-backport-of-pr-9517
Backport PR #9517 on branch v2.1.x
2 parents aaecec4 + a3ec10b commit 473409e
Copy full SHA for 473409e

File tree

Expand file treeCollapse file tree

1 file changed

+28
-5
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+28
-5
lines changed

‎lib/matplotlib/widgets.py

Copy file name to clipboardExpand all lines: lib/matplotlib/widgets.py
+28-5Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,13 @@ def _update(self, event):
414414
self.set_val(val)
415415

416416
def set_val(self, val):
417+
"""
418+
Set slider value to *val*
419+
420+
Parameters
421+
----------
422+
val : float
423+
"""
417424
xy = self.poly.xy
418425
xy[2] = val, 1
419426
xy[3] = val, 0
@@ -429,25 +436,41 @@ def set_val(self, val):
429436

430437
def on_changed(self, func):
431438
"""
432-
When the slider value is changed, call *func* with the new
433-
slider position
439+
When the slider value is changed call *func* with the new
440+
slider value
434441
435-
A connection id is returned which can be used to disconnect
442+
Parameters
443+
----------
444+
func : callable
445+
Function to call when slider is changed.
446+
The function must accept a single float as its arguments.
447+
448+
Returns
449+
-------
450+
cid : int
451+
Connection id (which can be used to disconnect *func*)
436452
"""
437453
cid = self.cnt
438454
self.observers[cid] = func
439455
self.cnt += 1
440456
return cid
441457

442458
def disconnect(self, cid):
443-
"""remove the observer with connection id *cid*"""
459+
"""
460+
Remove the observer with connection id *cid*
461+
462+
Parameters
463+
----------
464+
cid : int
465+
Connection id of the observer to be removed
466+
"""
444467
try:
445468
del self.observers[cid]
446469
except KeyError:
447470
pass
448471

449472
def reset(self):
450-
"""reset the slider to the initial value if needed"""
473+
"""Reset the slider to the initial value"""
451474
if (self.val != self.valinit):
452475
self.set_val(self.valinit)
453476

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.