Python绘制三维图

 时间:2024-10-13 22:52:40

1、绘制3D柱状图,其数据格式为,二维数组或三维数组。酆璁冻嘌from numpy import *file=open(&垆杪屑丝#39;C:\\Users\\jyjh\\Desktop\\count.txt','r')arr=[]for i in file.readlines(): temp=[] for j in i.strip().split('\t'): temp.append(float(j)) arr.append(temp)import randomimport numpy as npimport matplotlib as mplimport matplotlib.pyplot as pltfrom mpl_toolkits.mplot3d import Axes3Dmpl.rcParams['font.size']=10fig=plt.figure()ax=fig.add_subplot(111,projection='3d')xs=range(len(arr))ys=range(len(arr[0]))for z in range(len(arr)): xs=range(len(arr)) ys=arr[z] color=plt.cm.Set2(random.choice(range(plt.cm.Set2.N))) ax.bar(xs,ys,zs=z,zdir='y',color=color,alpha=0.5) ax.xaxis.set_major_locator(mpl.ticker.FixedLocator(xs)) ax.yaxis.set_major_locator(mpl.ticker.FixedLocator(ys))ax.set_xlabel('x')ax.set_ylabel('y')ax.set_zlabel('copies')plt.show()通过设置xs,ys,z可以设定绘制不同维度的数据。

Python绘制三维图Python绘制三维图Python绘制三维图Python绘制三维图Python绘制三维图
  • excel表格如何插入三维曲面图
  • 如何在PPT中插入放大镜3D模型
  • 如何开启车轮驾考通的答题插件
  • Lingo怎样从文件导入创建对象
  • Excel如何让数据按照小数点对齐
  • 热门搜索
    旅游风景图片 杭州旅游景点大全 芽庄旅游 会议旅游 阆中旅游攻略 衡水旅游 栾川旅游 北京旅游团 虚拟旅游 海边旅游景点