1. 绘制3D柱状图,其数据格式为,二维数组或三维数组。

    from numpy import *

    file=open('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 random

    import numpy as np

    import matplotlib as mpl

    import matplotlib.pyplot as plt

    from mpl_toolkits.mplot3d  import Axes3D

    mpl.rcParams['font.size']=10

    fig=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可以设定绘制不同维度的数据。

  2. 绘制热图:

    import numpy as np

    from matplotlib import pyplot as plt

    from matplotlib import cm

    from matplotlib import axes

    def draw_heatmap(data,xlabels,ylabels):

    #cmap = cm.get_cmap('rainbow',1000)

    cmap=cm.gray

    figure=plt.figure(facecolor='w')

    ax=figure.add_subplot(2,1,1,position=[1,1,1,1])

    ax.set_yticks(range(len(ylabels)))

    ax.set_yticklabels(ylabels)

    ax.set_xticks(range(len(xlabels)))

    ax.set_xticklabels(xlabels)

    vmax=data[0][0]

    vmin=data[0][0]

    for i in data:

    for j in i:

    if j>vmax:

    vmax=j

    if j<vmin:

    vmin=j

    map=ax.imshow(data,interpolation='nearest',cmap=cmap,aspect='auto',vmin=vmin,vmax=vmax)

    cb=plt.colorbar(mappable=map,cax=None,ax=None,shrink=0.8)

    plt.show()

    xl=range(16)

    yl=range(16)

    draw_heatmap(arr,xl,yl)

  3. 绘制曲面图

    from matplotlib import pyplot as plt

    import numpy as np

    from mpl_toolkits.mplot3d import Axes3D

    figure = plt.figure()

    ax = Axes3D(figure)

    X = np.arange(-10, 10, 0.25)

    Y = np.arange(-10, 10, 0.25)

    #网格化数据

    X, Y = np.meshgrid(X, Y)

    R = np.sqrt(X**2 + Y**2)

    Z = np.cos(R)

    ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap='rainbow')

    plt.show()

  4. 绘制曲线图

    from mpl_toolkits.mplot3d import Axes3D

    import numpy as np

    import matplotlib.pyplot as plt

    #生成画布

    figure=plt.figure()

    ax=figure.add_subplot(111,projection='3d')

    #生成向量

    z=np.linspace(0,6,1000)

    r=1

    x=r*np.sin(np.pi*2*z)

    y=r*np.cos(np.pi*2*z)

    ax.plot(x,y,z)

    plt.show()

python 三维坐标图的更多相关文章

  1. iOS绘制坐标图,折线图-Swift

    坐标图,经常会在各种各样的App中使用,最常用的一种坐标图就是折线图,根据给定的点绘制出对应的坐标图是最基本的需求.由于本人的项目需要使用折线图,第一反应就是搜索已经存在的解决方案,因为这种需求应该很 ...

  2. 基于osg的python三维程序开发(一)

    背景: osg是一款开源的三维引擎,在过去多年的发展中积累了大量的用户,该引擎基于场景树的管理,使用方法简单.但是对长期使用python作为开发工具的朋友来说, 有一定门槛. 下面的小程序,演示了如何 ...

  3. Swift基础之设计折线坐标图

    最近添加了折线视图的样式,所以在这里用Swift语言重新再使用设计一下 首先设置纵坐标的数值是:体重 //体重        let weightLabel = UILabel.init(frame: ...

  4. python 三维数组找最小值

    #声明三维数组 num=[[[,,],[,,],[,,]], \ [[,,],[,,],[,,]]] value=num[][][]#设置main为num数组的第一个元素 ): ): ): if(va ...

  5. 基于osg的python三维程序开发(三)------几何形体及纹理

    def createScene(): geode = osg.Geode() pointsGeom = osg.Geometry() vertices = osg.Vec3Array() vertic ...

  6. 基于osg的python三维程序开发(二)------向量

    上一篇文章展示了如何简单创建一个osg python 程序, 本篇展示了了一些基础数据结构的使用: from pyosg import * vec = osg.Vec3Array() #push ba ...

  7. python 三维散点插值 griddata

    #三维点插值#在三维空间中,利用实际点的值推算出网格点的值import numpy as np point_grid =np.array([[0.0,0.0,0.0],[0.4,0.4,0.4],[0 ...

  8. Matplotlib:Python三维绘图

    1.创建三维坐标轴对象Axes3D 创建Axes3D主要有两种方式,一种是利用关键字projection='3d'来实现,另一种是通过从mpl_toolkits.mplot3d导入对象Axes3D来实 ...

  9. Android动画translate坐标图

    X坐标图示: Y坐标图示:

随机推荐

  1. Codeforces Beta Round #19D(Points)线段树

    D. Points time limit per test 2 seconds memory limit per test 256 megabytes input standard input out ...

  2. mac 解决mysql启动不了

    mac升级了mysql,没有替换原来的链接的情况下, 启动mysql restart 会失败 解决方法,找到mysql真正的安装目录 mysql.server start

  3. MySql 基础 基本使用方法

    安装MySQL linux安装:阿里云服务器ecs配置之安装mysqlwindows安装: 解压 管理员身份进cmd执行解压目录下的可执行文件 初始化 D:\mysql-8.0.12-winx64\m ...

  4. 杭电 1789 Doing Homework again (贪心 求最少扣分)

    Description zichen has just come back school from the 30th ACM/ ICPC. Now he has a lot of homework t ...

  5. String类的概述和构造方法

    StringDemo.java /* * String:字符串类 * 由多个字符组成的一串数据 * 字符串其本质就是一个字符数组 * * 构造方法: * String(String original) ...

  6. 使用IDEA部署Myeclipse项目----亲测有效

    使用IDEA部署Myeclipse项目-----https://blog.csdn.net/u010570551/article/details/51510447

  7. Linux下汇编语言学习笔记17 ---

    这是17年暑假学习Linux汇编语言的笔记记录,参考书目为清华大学出版社 Jeff Duntemann著 梁晓辉译<汇编语言基于Linux环境>的书,喜欢看原版书的同学可以看<Ass ...

  8. SOJ 2930_积木城堡

    [题意]若干个城堡,给定每个城堡的积木数及每块积木的棱长.从城堡中抽出积木使每块城堡高度相同,求最大高度 [分析]城堡的积木选择可以看成01背包问题,从最矮的城堡高度开始依次递减,求出使每个背包都能装 ...

  9. php-7.1编译记录

    编译php-7.1.28步骤 检查环境 ./configure \ --prefix=/u01/server/php-7.1.28 \ --enable-fpm \ --with-fpm-user=d ...

  10. [React] Prevent Unnecessary Rerenders of Compound Components using React Context

    Due to the way that React Context Providers work, our current implementation re-renders all our comp ...