How to add wireframe, surface, and triangular surface plots

By considering the plot not just as a bunch of points, but as something filled in, we can use either the wireframe keyword or the wireframe method on the new axes, as shown here:

# Wireframe plot: r/c, stride & countfig = 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 = -160*np.power(r,2)+np.power(r,4)ax.plot_wireframe(x,y,goldstone)
  1. In the preceding snippet, we pass x, y and goldstone, which gives us a nice surface, as shown here:

  1. In order to change how Matplotlib decides ...

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.