当前位置:首页 > Python教程 > python技巧

python matplotlib 最简易懂实现三维图表可视化,(颜色渐变)

效果图:

技术分享图片

 

代码:

             1
            from matplotlib import pyplot as plt
 2import numpy as np
 3from mpl_toolkits.mplot3d import Axes3D
 4     fig = plt.figure()
 5     ax = Axes3D(fig)
 6     X = np.arange(-4, 4, 0.25)
 7     Y = np.arange(-4, 4, 0.25)
 8     X, Y = np.meshgrid(X, Y)
 9     R = np.sqrt(X ** 2 + Y ** 2)
10     Z = np.sin(R)
11     ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=rainbow)
12     plt.show()

 

原文:https://www.cnblogs.com/smartisn/p/12914033.html


【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!