python-三維圖形的繪制
import matplotlib.pyplot as plt
import mpl_toolkits.axisartist as axis
import numpy as np
import mpl_toolkits.mplot3d
x,y = np.mgrid[-2:2:20j,-2:2:20j]
z = (x**2 + y**2)
'''
三維建模
'''
ax = plt.subplot(111, projection='3d')
ax.set_title('f(x,y)=x^2+y^2')
ax.plot_surface(x,y,z,rstride=9, cstride=1, cmap=plt.cm.Blues_r)
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('z')
plt.show()
標(biāo)簽: