Skip to content

Commit 9966109

Browse files
committed
Update comments and docstring for RangeSlider + SliderBase
1 parent 687339b commit 9966109

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

lib/matplotlib/widgets.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,12 @@ def disconnect(self, cid):
230230

231231

232232
class SliderBase(AxesWidget):
233+
"""
234+
The base class for constructing Slider widgets. Not intended for direct
235+
usage.
236+
237+
For the slider to remain responsive you must maintain a reference to it.
238+
"""
233239
def __init__(self, ax, orientation, closedmin, closedmax,
234240
valmin, valmax, valfmt, dragging, valstep):
235241
if ax.name == '3d':
@@ -526,11 +532,12 @@ def on_changed(self, func):
526532

527533
class RangeSlider(SliderBase):
528534
"""
529-
A slider representing a floating point range.
535+
A slider representing a range of floating point values. Defines the min and
536+
max of the range via the *val* attribute as a tuple of (min, max).
530537
531-
Create a slider from *valmin* to *valmax* in axes *ax*. For the slider to
532-
remain responsive you must maintain a reference to it. Call
533-
:meth:`on_changed` to connect to the slider event.
538+
Create a slider that defines a range contained within [*valmin*, *valmax*]
539+
in axes *ax*. For the slider to remain responsive you must maintain a
540+
reference to it. Call :meth:`on_changed` to connect to the slider event.
534541
535542
Attributes
536543
----------
@@ -724,14 +731,13 @@ def _format(self, val):
724731
if self.valfmt is not None:
725732
return f"({self.valfmt % val[0]}, {self.valfmt % val[1]})"
726733
else:
727-
# fmt.get_offset is actually the multiplicative factor, if any.
728734
_, s1, s2, _ = self._fmt.format_ticks(
729735
[self.valmin, *val, self.valmax]
730736
)
731737
# fmt.get_offset is actually the multiplicative factor, if any.
732738
s1 += self._fmt.get_offset()
733739
s2 += self._fmt.get_offset()
734-
# use raw string to avoid issues with backslashes from
740+
# Use f string to avoid issues with backslashes when cast to a str
735741
return f"({s1}, {s2})"
736742

737743
def set_min(self, min):

0 commit comments

Comments
 (0)