How to add 3D contour types

We also have the ability to add contours to a 3D plot. Try the following code:

# Contour plot (filled/unfilled)fig = plt.figure()ax = fig.add_subplot(111, projection='3d')x,y = np.meshgrid(np.arange(-10,10,0.5), np.arange(-10,10,0.5))r = np.linalg.norm([x,y], axis=0)goldstone = -200*np.power(r,2)+np.power(r,4)ax.contour(x,y,goldstone)

From this code, we get a nice set of contours in 3D, as shown here:

By adding the letter f ahead of contour, we get 3D filled contours, as shown here:

Hence, we see that, ...

Get Mastering Matplotlib 2.x now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.