diff --git a/lib/matplotlib/widgets.py b/lib/matplotlib/widgets.py index 6c7bc0936d70..1af736df6053 100644 --- a/lib/matplotlib/widgets.py +++ b/lib/matplotlib/widgets.py @@ -422,6 +422,13 @@ def _update(self, event): self.set_val(val) def set_val(self, val): + """ + Set slider value to *val* + + Parameters + ---------- + val : float + """ xy = self.poly.xy xy[2] = val, 1 xy[3] = val, 0 @@ -437,10 +444,19 @@ def set_val(self, val): def on_changed(self, func): """ - When the slider value is changed, call *func* with the new - slider position + When the slider value is changed call *func* with the new + slider value - A connection id is returned which can be used to disconnect + Parameters + ---------- + func : callable + Function to call when slider is changed. + The function must accept a single float as its arguments. + + Returns + ------- + cid : int + Connection id (which can be used to disconnect *func*) """ cid = self.cnt self.observers[cid] = func @@ -448,14 +464,21 @@ def on_changed(self, func): return cid def disconnect(self, cid): - """remove the observer with connection id *cid*""" + """ + Remove the observer with connection id *cid* + + Parameters + ---------- + cid : int + Connection id of the observer to be removed + """ try: del self.observers[cid] except KeyError: pass def reset(self): - """reset the slider to the initial value if needed""" + """Reset the slider to the initial value""" if (self.val != self.valinit): self.set_val(self.valinit)