Here is the explanation of the code:
- a and b are the limits of integral for which we need to plot the area.
- x is an array of 50 (default) values spread equally in between 0 and 10, and y is a third-order polynomial of x.
- plt.plot(x, y, 'r', linewidth=2) plots the polynomial curve, and plt.ylim(0) sets the lower limit for the y axis to 0.
- intx is an array of 50 points spread equally between a and b.
- inty is an array of 50 points corresponding to 50 points in intx, which fall on the polynomial curve between a and b.
- verts is a list of points that form the polynomial from point (a,0) to all the points formed by intx and inty, followed by (b,0).
- poly = Polygon(verts, facecolor='0.9', edgecolor='0.5') defines the polygon formed ...