I am plotting contours for various levels on an image with matplotlib. I'd like to compute the total area enclosed in all contours above a given contour level. Here's an example of the code I am starting with:
import matplotlib.pyplot as plt
ax = plt.subplot()
myimage = ax.imshow(im.T,interpolation='nearest',origin='lower',norm=LogNorm(),extent=ext)
mylevels=[1e-3,1e-2,1e-1]
cs = plt.contour(im.T,levels=mylevels,colors['white','yellow','red'],origin='lower')
The image im
can be whatever 2d image here.
This will generate many contours, and what I am wondering is how to compute the total area enclosed within e.g. the first contour level. Any idea ?
Thanks.