21
21
def f (t , amplitude , frequency ):
22
22
return amplitude * np .sin (2 * np .pi * frequency * t )
23
23
24
- t = np .arange ( 0.0 , 1.0 , 0.001 )
24
+ t = np .linspace ( 0 , 1 , 1000 )
25
25
26
26
# Define initial parameters
27
27
init_amplitude = 5
@@ -30,6 +30,7 @@ def f(t, amplitude, frequency):
30
30
# Create the figure and the line that we will manipulate
31
31
fig , ax = plt .subplots ()
32
32
line , = plt .plot (t , f (t , init_amplitude , init_frequency ), lw = 2 )
33
+ ax .set_xlabel ('Time [s]' )
33
34
34
35
axcolor = 'lightgoldenrodyellow'
35
36
ax .margins (x = 0 )
@@ -41,19 +42,19 @@ def f(t, amplitude, frequency):
41
42
axfreq = plt .axes ([0.25 , 0.1 , 0.65 , 0.03 ], facecolor = axcolor )
42
43
freq_slider = Slider (
43
44
ax = axfreq ,
44
- label = 'Frequency' ,
45
+ label = 'Frequency [Hz] ' ,
45
46
valmin = 0.1 ,
46
- valmax = 30.0 ,
47
- valinit = init_amplitude ,
47
+ valmax = 30 ,
48
+ valinit = init_frequency ,
48
49
)
49
50
50
51
# Make a vertically oriented slider to control the amplitude
51
52
axamp = plt .axes ([0.1 , 0.25 , 0.0225 , 0.63 ], facecolor = axcolor )
52
53
amp_slider = Slider (
53
54
ax = axamp ,
54
55
label = "Amplitude" ,
55
- valmin = 0.1 ,
56
- valmax = 10.0 ,
56
+ valmin = 0 ,
57
+ valmax = 10 ,
57
58
valinit = init_amplitude ,
58
59
orientation = "vertical"
59
60
)
0 commit comments