Python 使用公共基名称打印多个文件
我有100个包含两列的.txt文件。文件名为file0、file1、file2、…、file99。我想把它们都画在一张图上。如何在gnuplot、python、matlab或C中实现这一点?如果您可以用python读入它们,将它们放入一组列表中,并使用像Plotly这样的声明性绘图包,那就不难了 虽然Matplotlib快速且简单,但有时要做看起来显而易见的事情需要比我想象的更多的工作,尤其是在大量数据点最终变得混乱的情况下。在gnuplot中:Python 使用公共基名称打印多个文件,python,matlab,plot,gnuplot,multiple-columns,Python,Matlab,Plot,Gnuplot,Multiple Columns,我有100个包含两列的.txt文件。文件名为file0、file1、file2、…、file99。我想把它们都画在一张图上。如何在gnuplot、python、matlab或C中实现这一点?如果您可以用python读入它们,将它们放入一组列表中,并使用像Plotly这样的声明性绘图包,那就不难了 虽然Matplotlib快速且简单,但有时要做看起来显而易见的事情需要比我想象的更多的工作,尤其是在大量数据点最终变得混乱的情况下。在gnuplot中: # Example Python impleme
# Example Python implementation using matplotlib
import numpy as np
import matplotlib.pyplot as plt
delim = "," # Whatever delimiter your txt file uses
basename = "file"
numFiles = 100
plt.figure()
for i in range(numFiles):
filename = basename + str(i) + ".txt"
data = np.loadtxt(filename, delimiter=delim)
print data.shape
plt.plot(data[:,0], data[:,1])
plt.show()
plot for [n=0:99] "file".n with lp
当然,您可以根据需要使用不同的样式、指令等修改plot命令