概述
例子代码如下:
import matplotlib.pyplot as plt
def zfunc(x):
return (x[0] ** 2 + x[1] - 11) ** 2 + (x[0] + x[1] ** 2 - 7) ** 2
# 可视化
x = np.arange(-6, 6, 0.1)
y = np.arange(-6, 6, 0.1)
print('x,y range:', x.shape, y.shape)
X, Y = np.meshgrid(x, y)
print('X,Y maps:', X.shape, Y.shape)
Z = zfunc([X, Y])
flg = plt.figure('zfunc')
ax = flg.add_subplot(projection='3d')
ax.plot_surface(X, Y, Z)
ax.view_init(-60, 30)
ax.set_xlable = ('x')
ax.set_ylable = ('y')
plt.show()
图像如下:
最后
以上就是缓慢小天鹅为你收集整理的python使用matplotlib包画出3d图像的全部内容,希望文章能够帮你解决python使用matplotlib包画出3d图像所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复