File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ from pylab import *
2+ from matplotlib .widgets import Button
3+
4+ freqs = arange (2 ,20 ,3 )
5+
6+ ax = subplot (111 )
7+ subplots_adjust (bottom = 0.2 )
8+ t = arange (0.0 , 1.0 , 0.001 )
9+ s = sin (2 * pi * freqs [0 ]* t )
10+ l , = plot (t ,s , lw = 2 )
11+
12+
13+ class Index :
14+ ind = 0
15+ def next (self , event ):
16+ self .ind += 1
17+ i = self .ind % len (freqs )
18+ ydata = sin (2 * pi * freqs [i ]* t )
19+ l .set_ydata (ydata )
20+ draw ()
21+
22+ def prev (self , event ):
23+ self .ind -= 1
24+ i = self .ind % len (freqs )
25+ ydata = sin (2 * pi * freqs [i ]* t )
26+ l .set_ydata (ydata )
27+ draw ()
28+
29+ callback = Index ()
30+ axprev = axes ([0.7 , 0.05 , 0.1 , 0.075 ])
31+ axnext = axes ([0.81 , 0.05 , 0.1 , 0.075 ])
32+ bnext = Button (axnext , 'Next' )
33+ bnext .on_clicked (callback .next )
34+ bprev = Button (axprev , 'Previous' )
35+ bprev .on_clicked (callback .prev )
36+
37+ show ()
38+
You can’t perform that action at this time.
0 commit comments