例子代码如下:
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17import 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图像内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复