欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

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

實例如下:

# -*- 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,則默認每次取list中的一個元素,即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 鼠標左鍵按下 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的方法就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • Python 正則表達式的高級用法

    Python 正則表達式的高級用法

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

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

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

    scrapy框架攜帶cookie訪問淘寶購物車功能的實現(xiàn)代碼

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

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

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

    python讀寫ini配置文件方法實例分析

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

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

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

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

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

    淺談django中的認證與登錄

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

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

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

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

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

最新評論