1. 最近在测试一款设备,采集了一些设备后需要一帧一帧显示图像,经常使用Python,所以选用了Matplotlib进行图像操作

数据结构: timesatamp polar_distance horizontal_angle refelectivity_intensity,所有数据类型都是 float,储存在文件内并且以空格分隔

import math
import matplotlib.pyplot as plt #read data from file
def LoadData(filename):
inFile = open(filename, 'r') #declare two empty list,to save data
inten = []
polar_dist = []
hori_angle = [] for line in inFile:
splitline = line.split(" ")
polar_dist.append(splitline[1])
hori_angle.append(splitline[2])
inten.append(splitline[3])
inFile.close() #mapping to float
polar_dist = list(map(float,polar_dist))
hori_angle = list(map(float,hori_angle))
inten = list(map(float,inten)) return(polar_dist, hori_angle,inten)

2. 显示极坐标图像

def GenerateImageFromData(polar,angle,inten):
d2r = math.pi/180
for i in range(len(polar)):
angle[i] = d2r*(angle[i] +180)
plt.ion()
  #inreactive code
ax = plt.subplot(111, projection='polar')
for i in range(100):
c = ax.scatter(angle[i*167 :(i+1)*167], polar[i*167 :(i+1)*167], s = 10)
plt.show()
plt.pause(1)

3. 调用函数

if __name__=="__main__":
(polar,angle,inten) = LoadData("CloudData.txt")
GenerateImageFromData(polar,angle,inten)

当绘图语句中加入pl.ion()时,表示打开了交互模式。此时python解释器解释完所有命令后,给你出张图,但不会结束会话,而是等着你跟他交流交流。如果你继续往代码中加入语句,run之后,你会实时看到图形的改变。当绘图语句中加入pl.ioff()时或不添加pl.ion()时,表示打关了交互模式。

4. 另外一个example

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Nov 16 21:26:17 2017 @author: XX
""" import matplotlib.pylab as plt
import numpy as np
import math #clear images
plt.close() fig = plt.figure()
ax = fig.add_subplot(111) #ratio of x and y axis
ax.axis("equal") #enable grid of image
ax.grid(True) #activate inreactivate mode
plt.ion() init_x = 0.0
init_y = 3.5
init_angle = 45
init_wind_speed = 3 print("inreactive mode beginning")
try:
for t in range(50):
x = init_x + init_wind_speed*math.sin(math.pi/180*init_angle)*t
y = init_y + init_wind_speed*math.cos(init_angle*math.pi/180)*t
ax.scatter(x,y,c='r', s =5, marker ='^')
plt.pause(0.2)
except Exception as err:
print(err)

Python Matplotlib.plot Update image Questions的更多相关文章

  1. python matplotlib plot 数据中的中文无法正常显示的解决办法

    转发自:http://blog.csdn.net/laoyaotask/article/details/22117745?utm_source=tuicool python matplotlib pl ...

  2. python matplotlib.plot画图显示中文乱码的问题

    在matplotlib.plot生成的统计图表中,中文总是无法正常显示.在网上也找了些资料,说是在程序中指定字体文件,不过那样的话需要对plot进行很多设置,而且都是说的设置坐标轴标题为中文,有时候图 ...

  3. 使用Python matplotlib做动态曲线

    今天看到“Python实时监控CPU使用率”的教程: https://www.w3cschool.cn/python3/python3-ja3d2z2g.html 自己也学习如何使用Python ma ...

  4. python matplotlib 中文显示乱码设置

    python matplotlib 中文显示乱码设置 原因:是matplotlib库中没有中文字体.1 解决方案:1.进入C:\Anaconda64\Lib\site-packages\matplot ...

  5. Python - matplotlib 数据可视化

    在许多实际问题中,经常要对给出的数据进行可视化,便于观察. 今天专门针对Python中的数据可视化模块--matplotlib这块内容系统的整理,方便查找使用. 本文来自于对<利用python进 ...

  6. 转:使用 python Matplotlib 库 绘图 及 相关问题

     使用 python Matplotlib 库绘图      转:http://blog.csdn.net/daniel_ustc/article/details/9714163 Matplotlib ...

  7. 安装python Matplotlib 库

    转:使用 python Matplotlib 库 绘图 及 相关问题  使用 python Matplotlib 库绘图      转:http://blog.csdn.net/daniel_ustc ...

  8. python matplotlib 中文显示参数设置

    python matplotlib 中文显示参数设置 方法一:每次编写代码时进行参数设置 #coding:utf-8import matplotlib.pyplot as pltplt.rcParam ...

  9. python matplotlib画图产生的Type 3 fonts字体没有嵌入问题

    ScholarOne's 对python matplotlib画图产生的Type 3 fonts字体不兼容,更改措施: 在程序中添加如下语句 import matplotlib matplotlib. ...

随机推荐

  1. cmd命令之查看进程到杀掉进程

    1. cmd命令查看当前进程 netstat -ano | findstr “port”

  2. C++之结构体struct

    原创博客,转载请注明出处! 1.简介 # C++提供一些基本的数据类型(int,float,double,char等),但由于程序处理的问题通常较复杂,基本的数据类型不能满足程序需要,因此C++允许用 ...

  3. UVALive - 3490 Generator (AC自动机+高斯消元dp)

    初始有一个空串s,从前n个大写字母中不断随机取出一个字母添加到s的结尾,出现模式串t时停止,求停止时s的长度期望. 这道题解法不唯一,比较无脑的方法是对模式串t建一个单串AC自动机,设u为自动机上的一 ...

  4. Java处理乱码问题

    中文乱码分为GET乱码和POST乱码 GET乱码在Tomcat中配置编码 <Connector port="8080" protocol="HTTP/1.1&quo ...

  5. linux 内核的链表操作(好文不得不转)

    以下全部来自于http://www.ibm.com/developerworks/cn/linux/kernel/l-chain/index.html 无任何个人意见. 本文详细分析了 2.6.x 内 ...

  6. 如何安装搜索引擎Elasticsearch?

    最近工作中要用到搜索引擎,由于目前用的搜索引擎是LeanCloud 提供的 ,不太好用,不支持范围等搜索,而且每天还收费30元,请求次数也有限制.基于这些原因,我们只好在自己的服务器上部署搜索引擎了. ...

  7. HDU3887(树dfs序列+树状数组)

    Counting Offspring Time Limit: 15000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...

  8. 使用script转储终端命令输出,或者录制并播放session的内容

    摘自:http://leohot.blog.163.com/blog/static/1348656022012729113658473/ 注意: 1. 启动script时没有指定文件名,它会自动记录到 ...

  9. 我和domino不得不说的故事(连载2016-3-2)

    1.关于NotesViewEntry 注意:通过NotesViewEntry获取某列的值时,若该列的值为@IsExpandable or @DocNumber 或者是常量时,将不会显示. Set en ...

  10. Redis codis 搭建测试

    codis Codis 是一个分布式 Redis 解决方案, 对于上层的应用来说, 连接到 Codis Proxy 和连接原生的 Redis Server 没有明显的区别,有部分命令支持 Codis ...