python根據數組數據繪圖


轉載自網絡,版權歸原作者所有

hello3.txt文件內部數據如下

。。。。。。7,2,6,-12,-10,-7,-1,2,9,。。。。。。

python腳本

import numpy as np
import pylab as pl
import math
import codecs
file=codecs.open("hello3.txt","r")
lines=" "
for line in file.readlines():
    lines=lines+line
ys=lines.split(",")
yss=[]
ays=list()
axs=list()
i=0
max1=pow(2,16)-1
for y in ys:
    if y.strip()=="":
        continue
    yss.append(y)

for index in range(len(yss)):

    y1=yss[index]

    i+=1;
    y=int(y1)

    ays.append(y)
    axs.append(i)
#print  i
file.close()
pl.plot(axs, ays,"ro")# use pylab to plot x and y
pl.show()# show the plot on the screen

結果


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM