# Author: Ika, 2013-09-14
import numpy as np
import matplotlib.pyplot as plt
import scipy.special as sp
from matplotlib.patches import Polygon
import random
fig=plt.figure()
ax = fig.add_subplot(111)
ax.set_xlim(0,2)
ax.set_ylim(0,4)
X = np.arange(0,2.01,0.01)
Y = X*X
ax.plot(X, Y)
verts = [(0,0)] + zip(X,Y) + [(2,0)]
poly = Polygon(verts, facecolor='blue',alpha=0.5,edgecolor='blue')
ax.add_patch(poly)
plt.savefig("frame0100.jpg")
ord = 0;
while (ord<7):
plt.clf()
fig=plt.figure()
ax = fig.add_subplot(111)
interval = 1.0/(2**ord)
ax.set_xlim(0,2)
ax.set_ylim(0,4)
X = np.arange(0,2.01,0.01)
Y = X*X
ax.plot(X, Y)
ax.text(0.2,3.0,'Step=1/'+str(2**ord),size=36);
y=interval;
while (y<4+interval/2.0):
#verts = [((y-interval)**0.5,y)]+[(2,y)]+[(2,y-interval)]+[((y-interval)**0.5,y-interval)];
verts = [(y**0.5,y)]+[(2,y)]+[(2,y-interval)]+[(y**0.5,y-interval)];
poly = Polygon(verts, facecolor='blue', alpha=0.5,edgecolor='black')
ax.add_patch(poly)
y=y+interval;
plt.savefig("frame00"+str(ord)+".jpg");
ord = ord+1;