My code is as follows, the problem is instead of having one plot, I get 242 plots. I tried putting the plt.show()
outside the loop, it didn't work.
import numpy as np
import matplotlib.pyplot as plt
import csv
names = list()
with open('selected.csv','rb') as infile:
reader = csv.reader(infile, delimiter = ' ')
for row in reader:
names.append(row[0])
names.pop(0)
for j in range(len(names)):
filename = '/home/mh/Masters_Project/Sigma/%s.dat' %(names[j])
average, sigma = np.loadtxt(filename, usecols = (0,1), unpack = True, delimiter = ' ')
name = '%s' %(names[j])
plt.figure()
plt.xlabel('Magnitude(average)', fontsize = 16)
plt.ylabel('$\sigma$', fontsize = 16)
plt.plot(average, sigma, marker = '+', linestyle = '', label = name)
plt.legend(loc = 'best')
plt.show()