Следуя этому ответу How to plot 10 traces in same figure with different color in python? мне нужно построить много файлов с расширением .numpy которые сохраняются в моей тестовой папкеКак построить все файлы в одной папке на python?
import matplotlib.pyplot as plt
import numpy as np
import matplotlib
import os, sys
#Read in list of files. You might want to look into os.listdir()
path='/home/user/Desktop/test'
traces= os.listdir(path)
# Create figure
fig=plt.figure()
fig.show()
ax=fig.add_subplot(111)
# Grab colormap
cmap = matplotlib.cm.get_cmap('jet')
# Loop through traces and plot them
for j,trace in enumerate(traces):
# Load file
dataArray= np.load(trace)
# Grab color
c=cmap(float(j)/len(traces))
# Plot
ax.plot(dataArray.T,color=c)
plt.show()
Но у меня есть эта ошибка:
dataArray= np.load(trace)
File "/usr/lib/python2.7/dist-packages/numpy/lib/npyio.py", line 370, in load
fid = open(file, "rb")
IOError: [Errno 2] No such file or directory: 'trace14.npy'
Я бы очень благодарю вас, если вы можете мне помочь.
Спасибо, что работает – nass9801