python 三维坐标图
绘制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可以设定绘制不同维度的数据。



绘制热图:
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)


绘制曲面图
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()


绘制曲线图
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 三维坐标图的更多相关文章
- iOS绘制坐标图,折线图-Swift
坐标图,经常会在各种各样的App中使用,最常用的一种坐标图就是折线图,根据给定的点绘制出对应的坐标图是最基本的需求.由于本人的项目需要使用折线图,第一反应就是搜索已经存在的解决方案,因为这种需求应该很 ...
- 基于osg的python三维程序开发(一)
背景: osg是一款开源的三维引擎,在过去多年的发展中积累了大量的用户,该引擎基于场景树的管理,使用方法简单.但是对长期使用python作为开发工具的朋友来说, 有一定门槛. 下面的小程序,演示了如何 ...
- Swift基础之设计折线坐标图
最近添加了折线视图的样式,所以在这里用Swift语言重新再使用设计一下 首先设置纵坐标的数值是:体重 //体重 let weightLabel = UILabel.init(frame: ...
- python 三维数组找最小值
#声明三维数组 num=[[[,,],[,,],[,,]], \ [[,,],[,,],[,,]]] value=num[][][]#设置main为num数组的第一个元素 ): ): ): if(va ...
- 基于osg的python三维程序开发(三)------几何形体及纹理
def createScene(): geode = osg.Geode() pointsGeom = osg.Geometry() vertices = osg.Vec3Array() vertic ...
- 基于osg的python三维程序开发(二)------向量
上一篇文章展示了如何简单创建一个osg python 程序, 本篇展示了了一些基础数据结构的使用: from pyosg import * vec = osg.Vec3Array() #push ba ...
- python 三维散点插值 griddata
#三维点插值#在三维空间中,利用实际点的值推算出网格点的值import numpy as np point_grid =np.array([[0.0,0.0,0.0],[0.4,0.4,0.4],[0 ...
- Matplotlib:Python三维绘图
1.创建三维坐标轴对象Axes3D 创建Axes3D主要有两种方式,一种是利用关键字projection='3d'来实现,另一种是通过从mpl_toolkits.mplot3d导入对象Axes3D来实 ...
- Android动画translate坐标图
X坐标图示: Y坐标图示:
随机推荐
- Java线上应用故障排查
线上故障主要2种: CPU利用率很高, 内存占用率很大 一.CPU利用率很高 1. top查询那个进程CPU使用率高 2. 显示进程列表 ps -mp pid -o THREAD,tid,time 找 ...
- Qt笔记——各种组件和其他细碎用法
LineEdit 获取文本:ui->usrLineEdit->text() 清空内容:ui->pwdLineEdit->clear(); 定位光标:ui->usrLine ...
- JQuery_九大选择器
JQuery_九大选择器-----https://blog.csdn.net/pseudonym_/article/details/76093261
- linux & chmod & 777
linux & chmod & 777 https://github.com/xgqfrms-GitHub/Node-CLI-Tools/blob/master/bash-shell- ...
- BBS+Blog项目流程及补充知识点
项目流程: 1. 产品需求 (1)基于用户认证组件和Ajax实现登陆验证(图片验证码) (2)基于forms组件和Ajax实现注册功能 (3)设计系统首页(文章列表渲染) (4)设计个人站点页面 (5 ...
- Python模块:time、datetime、random、os、sys、optparse
time模块的方法: 时间戳表示的是从1970年1月1日00:00:00开始按秒计算的偏移量. struct_time时间元组,共有九个元素组.如下图: time.localtime([secs]): ...
- Linux下汇编语言学习笔记53 ---
这是17年暑假学习Linux汇编语言的笔记记录,参考书目为清华大学出版社 Jeff Duntemann著 梁晓辉译<汇编语言基于Linux环境>的书,喜欢看原版书的同学可以看<Ass ...
- web文件管理系统和日志实时监控工具
https://blog.csdn.net/xuesong123/article/details/52752384
- hdu - 1104 Remainder (bfs + 数论)
http://acm.hdu.edu.cn/showproblem.php?pid=1104 注意这里定义的取模运算和计算机的%是不一样的,这里的取模只会得到非负数. 而%可以得到正数和负数. 所以需 ...
- 网页js粘贴截图
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...