Jun-10-2021, 01:26 PM
Hey,
I'm trying to plot the sum of 25 data files with 5 columns. The code is this:
I'm trying to plot the sum of 25 data files with 5 columns. The code is this:
import matplotlib.pyplot as plt import numpy as np from glob import glob fnames = glob("C:/.../..._*.hst") data = [np.loadtxt(f) for f in fnames] x = np.sum(data[:,0])/25 y1 = np.sum(data[:,1])/25 y2 = np.sum(data[:,2])/25 plt.plot(x,y1, label='sync1') plt.plot(x,y2, label='sync2') plt.legend() plt.show()The error is:
x = np.sum(data[:,0])/25 TypeError: list indices must be integers or slices, not tupleIs it so that the data I've created are now arrays, or what could be the issue? I'm trying to sum data from a specific column in all files and plot it against data from another column from all files.