栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

与matplotlib堆叠的3d条形图

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

与matplotlib堆叠的3d条形图

要制作堆叠的3d条形图,您可以累积

dz
值并将其用作下一个条形的基础。这是一个例子:

from mpl_toolkits.mplot3d import Axes3Dimport matplotlib.pyplot as pltimport numpy as npfig = plt.figure()ax = fig.add_subplot(111, projection = "3d")ax.set_xlabel("x")ax.set_ylabel("y") ax.set_zlabel("z")ax.set_xlim3d(0,10)ax.set_ylim3d(0,10)xpos = [2,5,8,2,5,8,2,5,8]ypos = [1,1,1,5,5,5,9,9,9]zpos = np.zeros(9)dx = np.ones(9)dy = np.ones(9)dz = [np.random.random(9) for i in range(4)]  # the heights of the 4 bar sets_zpos = zpos   # the starting zpos for each barcolors = ['r', 'b', 'g', 'y']for i in range(4):    ax.bar3d(xpos, ypos, _zpos, dx, dy, dz[i], color=colors[i])    _zpos += dz[i]    # add the height of each bar to know where to start the nextplt.gca().invert_xaxis()plt.show()


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/407434.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号