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:
The error is:
Is 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.
I'm trying to plot the sum of 25 data files with 5 columns. The code is this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
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() |
1 2 3 |
x = np. sum (data[:, 0 ]) / 25 TypeError: list indices must be integers or slices, not tuple |