Skip to content

Commit c526615

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

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

lib/matplotlib/widgets.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,13 @@ 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+
Call :meth:`on_changed` to connect to the slider event.
239+
"""
233240
def __init__(self, ax, orientation, closedmin, closedmax,
234241
valmin, valmax, valfmt, dragging, valstep):
235242
if ax.name == '3d':
@@ -526,11 +533,12 @@ def on_changed(self, func):
526533

527534
class RangeSlider(SliderBase):
528535
"""
529-
A slider representing a floating point range.
536+
A slider representing a range of floating point values. Defines the min and
537+
max of the range via the *val* attribute as a tuple of (min, max).
530538
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.
539+
Create a slider that defines a range contained within [*valmin*, *valmax*]
540+
in axes *ax*. For the slider to remain responsive you must maintain a
541+
reference to it. Call :meth:`on_changed` to connect to the slider event.
534542
535543
Attributes
536544
----------
@@ -724,14 +732,13 @@ def _format(self, val):
724732
if self.valfmt is not None:
725733
return f"({self.valfmt % val[0]}, {self.valfmt % val[1]})"
726734
else:
727-
# fmt.get_offset is actually the multiplicative factor, if any.
728735
_, s1, s2, _ = self._fmt.format_ticks(
729736
[self.valmin, *val, self.valmax]
730737
)
731738
# fmt.get_offset is actually the multiplicative factor, if any.
732739
s1 += self._fmt.get_offset()
733740
s2 += self._fmt.get_offset()
734-
# use raw string to avoid issues with backslashes from
741+
# Use f string to avoid issues with backslashes when cast to a str
735742
return f"({s1}, {s2})"
736743

737744
def set_min(self, min):

0 commit comments

Comments
 (0)