# The Barnsley Fern is a fractal named after the British mathematician # Michael Barnsley who first described it in his book Fractals Everywhere. # He made it to resemble the Black Spleenwort, Asplenium adiantum-nigrum. import numpy as np import matplotlib.pyplot as plt N=1000000 x=0.0 y=0.0 z=np.zeros((2,N)) for j in range(N): rnd=np.random.random() if rnd<=0.85: # 85% x2=0.85*x+0.04*y y2=-0.04*x+0.85*y+1.6 elif rnd<=0.92: # 7% x2=0.2*x-0.26*y y2=0.23*x+0.22*y+1.6 elif rnd<=0.99: # 7% x2=-0.15*x+0.28*y y2=0.26*x+0.24*y+0.44 else: # 1% x2=0.0 y2=0.16*y x=x2 y=y2 z[:,j]=x,y plt.plot(z[0,:],z[1,:],linestyle="None",marker=".",markersize=1,color="#00FF00") plt.show()