Note
Go to the endto download the full example code.
contour(X, Y, Z)#
Plot contour lines.
Seecontour.

importmatplotlib.pyplotaspltimportnumpyasnpplt.style.use('_mpl-gallery-nogrid')# make dataX,Y=np.meshgrid(np.linspace(-3,3,256),np.linspace(-3,3,256))Z=(1-X/2+X**5+Y**3)*np.exp(-X**2-Y**2)levels=np.linspace(np.min(Z),np.max(Z),7)# plotfig,ax=plt.subplots()ax.contour(X,Y,Z,levels=levels)plt.show()