1 2 3 4 5 6 7 8 9 10 11 12 13 14
| import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure() ax = Axes3D(fig) x = np.arange(-4,4,0.25) y = np.arange(-4,4,0.25) x,y = np.meshgrid(x,y) B = x ** 2 - 10 * np.cos(2 * np.pi * x) + 10 R = y ** 2 - 10 * np.cos(2 * np.pi * y) + 10 Z = B + R ax.plot_surface(x,y,Z,rstride=1,cstride=1,cmap=plt.get_cmap('rainbow')) plt.show()
|