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. [转载]]Java开发如何在线打开Word文件

    此方案使用了PageOffice产品实现在线打开Word文档: 1. 首先从PageOffice官网下载产品开发包,http://www.zhuozhengsoft.com/dowm/ ,下载Page ...

  2. windows下安装 redis并开机自启动

    1,redis官方下载地址:https://redis.io/download,redis 64位下载地址:https://github.com/ServiceStack/redis-windows, ...

  3. Spring与RMI集成实现远程访问

    使用spring对RMI的支持,可以非常容易地构建你的分布式应用.在服务端,可以通过Spring的org.springframework.remoting.rmi.RmiServiceExporter ...

  4.  P2152 [SDOI2009]SuperGCD (luogu)

    Stein算法是一种计算两个数最大公约数的算法,是针对欧几里德算法在对大整数进行运算时,需要试商导致增加运算时间的缺陷而提出的改进算法. 算法思想: 由J. Stein 1961年提出的Stein算法 ...

  5. DNS分别在什么情况下使用UDP和TCP?

    看到一个题目问的是:DNS分别在什么情况下使用UDP和TCP? 仔细查了一下发现可查询的资料很少,大部分都把DNS所用协议归为UDP了其实不然,DNS同时占用UDP和TCP端口53,这种单个应用协议同 ...

  6. 461. Hamming Distance Add to List

    // 快速法求1的个数 int BitCount2(unsigned int n) { unsigned ; ; n; ++c) { n &= (n -) ; // 清除最低位的1 } ret ...

  7. vue切换样式

    在vue中使用事件来切换绑定的class样式,在vue-cli脚手架中的Home.vue中 <template> <div id="main"> <l ...

  8. JSONP原理及实现跨域方式

    今天做页面时,后台给了个接口:https://a.a.com/a/a.json,我页面的上线地址是:http://b.b.com.显而易见,因为浏览器同源策略的限制,通过ajax无法无法取得json的 ...

  9. (转载)Windows: "net use" command introduction

    1)建立空连接: net use ""IP"ipc$ "" /user:"" (一定要注意:这一行命令中包含了3个空格) 2)建立 ...

  10. /etc/ntp.conf

    摘录一: System:ubuntu10.04 配置文件路径:/etc/ntp.conf   配置格式:关键字(如server)    参数(如prefer) 以换行为结束,所以一个配置不能占多行. ...