8000 cleanup python 2isms · matplotlib/matplotlib@d07830c · GitHub
[go: up one dir, main page]

Skip to content

Commit d07830c

Browse files
ianhitimhoffm
andcommitted
cleanup python 2isms
Co-Authored-By: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
1 parent fc20f19 commit d07830c

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed
< 8000 div class="Diff-module__diffHeaderWrapper--rsdD4" style="--header-sticky-offset:0px">

examples/widgets/slider_demo.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
def f(t, amplitude, frequency):
2222
return amplitude * np.sin(2 * np.pi * frequency * t)
2323

24-
t = np.arange(0.0, 1.0, 0.001)
24+
t = np.linspace(0, 1, 1000)
2525

2626
# Define initial parameters
2727
init_amplitude = 5
@@ -30,6 +30,7 @@ def f(t, amplitude, frequency):
3030
# Create the figure and the line that we will manipulate
3131
fig, ax = plt.subplots()
3232
line, = plt.plot(t, f(t, init_amplitude, init_frequency), lw=2)
33+
ax.set_xlabel('Time [s]')
3334

3435
axcolor = 'lightgoldenrodyellow'
3536
ax.margins(x=0)
@@ -41,19 +42,19 @@ def f(t, amplitude, frequency):
4142
axfreq = plt.axes([0.25, 0.1, 0.65, 0.03], facecolor=axcolor)
4243
freq_slider = Slider(
4344
ax=axfreq,
44-
label='Frequency',
45+
label='Frequency [Hz]',
4546
valmin=0.1,
46-
valmax=30.0,
47-
valinit=init_amplitude,
47+
valmax=30,
48+
valinit=init_frequency,
4849
)
4950

5051
# Make a vertically oriented slider to control the amplitude
5152
axamp = plt.axes([0.1, 0.25, 0.0225, 0.63], facecolor=axcolor)
5253
amp_slider = Slider(
5354
ax=axamp,
5455
label="Amplitude",
55-
valmin=0.1,
56-
valmax=10.0,
56+
valmin=0,
57+
valmax=10,
5758
valinit=init_amplitude,
5859
orientation="vertical"
5960
)

0 commit comments

Comments
 (0)
0