1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
from pylab import *
def animate(x, b):
if animate.cnt>=100:
return
animate.cnt += 1
y = x*b*(1-x)
ax.plot(animate.cnt,y, 'o')
ax.axis([0, 100, 0, 1])
x = y
fig.canvas.draw()
fig.canvas.manager.window.after(50, animate, x, b)
animate.cnt = 0
x= 0.4
b = 4
matplotlib.rcParams['axes.unicode_minus'] = False
fig = plt.figure()
ax = fig.add_subplot(111)
fig.canvas.manager.window.after(50, animate, x, b)
ax.set_title('Chaos : x(t+1) = x(t) * b(1-x(t))')
grid(True)
plt.show() |