Sophie

Sophie

distrib > Fedora > 13 > i386 > media > updates > by-pkgid > dc303dcad9fdd039290b4e78a58ed938 > files > 870

python-matplotlib-0.99.1.2-4.fc13.i686.rpm

from pylab import *
from matplotlib.widgets import Button

freqs = arange(2,20,3)

ax = subplot(111)
subplots_adjust(bottom=0.2)
t = arange(0.0, 1.0, 0.001)
s = sin(2*pi*freqs[0]*t)
l, = plot(t,s, lw=2)


class Index:
    ind = 0
    def next(self, event):
        self.ind += 1
        i = self.ind%len(freqs)
        ydata = sin(2*pi*freqs[i]*t)
        l.set_ydata(ydata)
        draw()

    def prev(self, event):
        self.ind -= 1
        i = self.ind%len(freqs)
        ydata = sin(2*pi*freqs[i]*t)
        l.set_ydata(ydata)
        draw()

callback = Index()
axprev = axes([0.7, 0.05, 0.1, 0.075])
axnext = axes([0.81, 0.05, 0.1, 0.075])
bnext = Button(axnext, 'Next')
bnext.on_clicked(callback.next)
bprev = Button(axprev, 'Previous')
bprev.on_clicked(callback.prev)

show()