亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

python 讀取目錄下csv文件并繪制曲線v111的方法

 更新時(shí)間:2018年07月06日 08:41:30   作者:liang890319  
今天小編就為大家分享一篇python 讀取目錄下csv文件并繪制曲線v111的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧

實(shí)例如下:

# -*- coding: utf-8 -*-
"""
Spyder Editor
This temporary script file is located here:
C:\Users\user\.spyder2\.temp.py
"""
"""
Show how to modify the coordinate formatter to report the image "z"
value of the nearest pixel given x and y
V1.1.1 get all filenames in shortout dir choose one to analysis
"""
# coding: utf-8
 
import time
import string
import os 
import math 
import pylab
import csv
 
import numpy as np
from numpy import genfromtxt
import matplotlib
import matplotlib as mpl
from matplotlib.colors import LogNorm
from matplotlib.mlab import bivariate_normal
 
import matplotlib.pyplot as plt
import matplotlib.cm as cm
 
 
import matplotlib.animation as animation
 
  
pause = False
linenum=0
fileList=[]  #待處理文件路徑
for filename in os.listdir(r'D:\shortout'):
 pa='D:\shortout\%s'%filename
 fileList.append(pa)
 
#for files in range(0,len(fileList)):
 
metric = genfromtxt(fileList[0], delimiter=',')
lines=len(metric) 
#print len(metric)
#print len(metric[4])
#print metric[4] 
 
rowdatas=metric[:,0]
for index in range(len(metric[4])-1):
 a=metric[:,index+1]
 rowdatas=np.row_stack((rowdatas,a))
 
#print len(rowdatas)
#print len(rowdatas[4])
#print rowdatas[4] 
# 
 
#plt.figure(figsize=(38,38), dpi=80)
#plt.plot(rowdatas[4] )
#plt.xlabel('time')
#plt.ylabel('value')
#plt.title("USBHID data analysis")
#plt.show()
 
 
##如果是參數(shù)是list,則默認(rèn)每次取list中的一個(gè)元素,即metric[0],metric[1],... 
listdata=rowdatas.tolist()
print listdata[4]
#fig = plt.figure() 
#window = fig.add_subplot(111) 
#line, = window.plot(listdata[4] ) 
 
#plt.ion()
#fig, ax = plt.subplots()
#line, = ax.plot(listdata[4],lw=2)
#ax.grid()
 
 
fig = plt.figure() 
ax = fig.add_subplot(111) 
line, = ax.plot(listdata[4],lw=2 ) # I'm still not clear on this stucture...
ax.grid()
 
time_template = 'Data ROW = %d'
time_text = ax.text(0.05, 0.9, '', transform=ax.transAxes)
 
#ax = plt.axes(xlim=(0, 700), ylim=(0, 255)) 
#line, = ax.plot([], [], lw=2) 
def onClick(event):
 global pause
 pause ^= True
 print 'user click the mouse!'
 print 'you pressed', event.button, event.xdata, event.ydata
# event.button=1 鼠標(biāo)左鍵按下 2 中鍵按下 3 右鍵按下 
 
 
def getData(): 
 global listdata
 global linenum
 t = 0 
 while t < len(listdata[4]):
  if not pause: 
   linenum=linenum+1
  yield listdata[linenum-1]
# while t < len(listdata[4]): 
#  t = t + 1 
#  print t,t
#  yield t, t 
  
def update(data): 
 global linenum
 line.set_ydata(data) 
 time_text.set_text(time_template % (linenum))
 return line, 
 
def init():
# ax.set_ylim(0, 1.1)
# ax.set_xlim(0, 10)
# line.set_data(xdata)
 plt.xlabel('time')
 plt.ylabel('Time')
 plt.title('USBHID Data analysis')
 return line,
fig.canvas.mpl_connect('button_press_event', onClick) 
ani = animation.FuncAnimation(fig, update , getData , blit=False, interval=1*1000,init_func=init,repeat=False) 
plt.show() 
 
 
#my_data = genfromtxt('D:\export.csv', delimiter=',')
#rgbdata=my_data、255
#plt.figure(figsize=(38,38), dpi=80)
#
#for index in range(3):
# row9=rgbdata[:,index]
# print "row %d size is\n"%(index)
# plt.plot(row9 )
# plt.xlabel('time')
# plt.ylabel('value')
# plt.title("USBHID data analysis")
# plt.legend()
## plt.cla()
## plt.clf()
#plt.show()
#plt.figure(1)
#plt.imshow(rgbdata, interpolation='nearest')
#plt.grid(True)
 
#fig = plt.figure() # 新圖 0
#plt.savefig() # 保存
#plt.close('all') # 關(guān)閉圖 0
 

以上這篇python 讀取目錄下csv文件并繪制曲線v111的方法就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • Python 正則表達(dá)式的高級(jí)用法

    Python 正則表達(dá)式的高級(jí)用法

    作為一個(gè)概念而言,正則表達(dá)式對(duì)于Python來(lái)說(shuō)并不是獨(dú)有的。但是,Python中的正則表達(dá)式在實(shí)際使用過(guò)程中還是有一些細(xì)小的差別。本文是一系列關(guān)于Python正則表達(dá)式文章的其中一部分。
    2016-12-12
  • Python map和reduce函數(shù)用法示例

    Python map和reduce函數(shù)用法示例

    這篇文章主要介紹了Python map和reduce函數(shù)用法示例,本文給出了兩個(gè)函數(shù)的多個(gè)用法示例,需要的朋友可以參考下
    2015-02-02
  • scrapy框架攜帶cookie訪問(wèn)淘寶購(gòu)物車功能的實(shí)現(xiàn)代碼

    scrapy框架攜帶cookie訪問(wèn)淘寶購(gòu)物車功能的實(shí)現(xiàn)代碼

    這篇文章主要介紹了scrapy框架攜帶cookie訪問(wèn)淘寶購(gòu)物車,本文通過(guò)實(shí)例代碼圖文詳解給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-07-07
  • Python?pass函數(shù)使用及其應(yīng)用的詳解

    Python?pass函數(shù)使用及其應(yīng)用的詳解

    Python中,pass是一種空語(yǔ)句,即不做任何事情,只起到占位符的作用,本文主要介紹了Python?pass函數(shù)使用及其應(yīng)用的詳解,文中通過(guò)示例代碼介紹的非常詳細(xì),需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2023-07-07
  • python讀寫ini配置文件方法實(shí)例分析

    python讀寫ini配置文件方法實(shí)例分析

    這篇文章主要介紹了python讀寫ini配置文件方法,實(shí)例分析了Python針對(duì)ini配置文件的相關(guān)讀寫技巧,需要的朋友可以參考下
    2015-06-06
  • Python爬蟲實(shí)現(xiàn)使用beautifulSoup4爬取名言網(wǎng)功能案例

    Python爬蟲實(shí)現(xiàn)使用beautifulSoup4爬取名言網(wǎng)功能案例

    這篇文章主要介紹了Python爬蟲實(shí)現(xiàn)使用beautifulSoup4爬取名言網(wǎng)功能,結(jié)合實(shí)例形式分析了Python基于beautifulSoup4模塊爬取名言網(wǎng)并存入MySQL數(shù)據(jù)庫(kù)相關(guān)操作技巧,需要的朋友可以參考下
    2019-09-09
  • Python搜索引擎實(shí)現(xiàn)原理和方法

    Python搜索引擎實(shí)現(xiàn)原理和方法

    這篇文章主要介紹了Python搜索引擎實(shí)現(xiàn)原理和方法,并對(duì)大數(shù)據(jù)分析做了詳細(xì)解釋,喜歡的朋友參考一下。
    2017-11-11
  • 淺談django中的認(rèn)證與登錄

    淺談django中的認(rèn)證與登錄

    下面小編就為大家?guī)?lái)一篇淺談django中的認(rèn)證與登錄。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2016-10-10
  • Python 使用list和tuple+條件判斷詳解

    Python 使用list和tuple+條件判斷詳解

    這篇文章主要介紹了Python 使用list和tuple+條件判斷詳解,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2019-07-07
  • Python Numpy 自然數(shù)填充數(shù)組的實(shí)現(xiàn)

    Python Numpy 自然數(shù)填充數(shù)組的實(shí)現(xiàn)

    今天小編就為大家分享一篇Python Numpy 自然數(shù)填充數(shù)組的實(shí)現(xiàn),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2019-11-11

最新評(píng)論