Matplotlib is a python third-party library for drawing data, often used with numpy, etc. Here is a 3D drawing using Matplotlib

You can’t read too fast without forgetting

import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D fig = plt.figure() ax = X = np. Arange (-4, 4, 0.25) X, Y = np. Arange (-4, 4, 0.25) X, Y = np. Y) R = np.sqrt(X ** 2 + Y ** 2) Z = np.cos(R)#rstride and cstride are mainly related to the size of a grid on the graph. Rstride: span between rows. Cstride: span between columns
ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=plt.get_cmap('rainbow'))
ax.set_zlim(-2, 2)
# onto the plane z equals minus 2
ax.contourf(X, Y, Z, zdir='z', offset=-2, cmap=plt.get_cmap('rainbow'))
plt.show()
Copy the code

Running effect drawing