what the plot comes out to be currently 我正在从文本文件中提取信息,并将文件行分开,然后将其放入数组以进行绘制。我设置它的方式,当它是我为x和y而不是值绘制的数组集时,我不知道如何添加偏移量。数据是针对不同温度的一组频率范围内的峰值,因此每个温度的数据最终会相互叠加。我想对数据进行y偏移以查看每个光谱,然后为每个数据集添加real_T值的行标签(或图例,如果过于复杂)。提前致谢!
import glob
import numpy as np
import matplotlib.pyplot as plt
for filename in glob.glob('*.dat'):
linenumber=0
num_lines=sum(1 for line in open(filename))-7 #says how many lines
data=np.zeros((num_lines,2))
for line in open(filename, 'r'):
linenumber+=1
if linenumber==3:
actual_T=line[22:29] #pulls out actual temperature value
if linenumber==4:
set_T=line[18:25] #pulls out set temperature value from .dat
if linenumber>7:
array=(line.split("\t")) #data array for that line
data[linenumber-8,0]=array[0] #saves frequency values to data
data[linenumber-8,1]=array[1] #saves in phase values to data
plt.figure(1)
plt.plot(data[:,0], data[:,1])
plt.xlim(200,260) #frequency range of plot
#plt.legend()
print("1 plot done")
plt.show()
print(data[:,0])
print(data[:,1])