Когда я пытаюсь запустить следующий код
import matplotlib.pyplot as plt
import math
import numpy as np
from numpy.random import normal
masses = []
f = open( 'myfile.txt','r')
f.readline()
for line in f:
if line != ' ':
line = line.strip() # Strips end of line character
columns = line.split() # Splits into coloumn
mass = columns[8] # Column which contains mass values
mass = float(mass)
masses.append(mass)
mass = math.log10(mass)
#print(mass)
#gaussian_numbers = #normal(size=1000)
plt.hist(mass, bins = 50, normed = True)
plt.title("Gaussian Histogram")
plt.xlabel("Value")
plt.ylabel("Frequency")
plt.show()
Я получаю эту ошибку
Traceback (most recent call last):
File "C:\Documents and Settings\Khary\My Documents\Python\HALOMASS_READER_PLOTTER.py", line 23, in <module>
plt.hist(mass, bins = 50, normed = True)
File "C:\Python32\lib\site-packages\matplotlib\pyplot.py", line 2191, in hist
ret = ax.hist(x, bins, range, normed, weights, cumulative, bottom, histtype, align, orientation, rwidth, log, color, label, **kwargs)
File "C:\Python32\lib\site-packages\matplotlib\axes.py", line 7606, in hist
if isinstance(x, np.ndarray) or not iterable(x[0]):
TypeError: 'float' object is not subscriptable
Можно ли использовать поплавки при выполнении гистограмм или я что-то упускаю? Любая помощь будет принята с благодарностью.