Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 411bdde

Browse files
committed
Simplify explanation and remove valstep from example
1 parent 786e41b commit 411bdde

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

examples/widgets/slider_demo.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@
33
Slider
44
======
55
6-
Using the slider widget to control visual properties of your plot.
7-
86
In this example, sliders are used to control the frequency and amplitude of
9-
a sine wave. You can control many continuously-varying properties of your plot
10-
in this way.
7+
a sine wave.
118
12-
For a more detailed example of value snapping see
9+
For an example of having the slider snap to discrete values see
1310
:doc:`/gallery/widgets/slider_snap_demo`.
1411
1512
For an example of using a `matplotlib.widgets.RangeSlider` to define a range
@@ -30,7 +27,7 @@ def f(t, amplitude, frequency):
3027
init_amplitude = 5
3128
init_frequency = 3
3229

33-
# Create the figure and the `~.Line2D` that we will manipulate
30+
# Create the figure and the line that we will manipulate
3431
fig, ax = plt.subplots()
3532
line, = plt.plot(t, f(t, init_amplitude, init_frequency), lw=2)
3633

@@ -41,15 +38,13 @@ def f(t, amplitude, frequency):
4138
plt.subplots_adjust(left=0.25, bottom=0.25)
4239

4340
# Make a horizontal slider to control the frequency.
44-
# This slider will snap to discrete values as defind by ``valstep``.
4541
axfreq = plt.axes([0.25, 0.1, 0.65, 0.03], facecolor=axcolor)
4642
freq_slider = Slider(
4743
ax=axfreq,
4844
label='Frequency',
4945
valmin=0.1,
5046
valmax=30.0,
5147
valinit=init_amplitude,
52-
valstep=5.0
5348
)
5449

5550
# Make a vertically oriented slider to control the amplitude
@@ -64,11 +59,13 @@ def f(t, amplitude, frequency):
6459
)
6560

6661

62+
# The function to be called anytime a slider's value changes
6763
def update(val):
6864
line.set_ydata(f(t, amp_slider.val, freq_slider.val))
6965
fig.canvas.draw_idle()
7066

7167

68+
# register the update function with each slider
7269
freq_slider.on_changed(update)
7370
amp_slider.on_changed(update)
7471

0 commit comments

Comments
 (0)