In [1]:
import matplotlib.pyplot as plt
import numpy as np
import matplotlib.mlab as mlab
%matplotlib inline
In [2]:
data=np.genfromtxt('data/histogramm.txt')  #Hier der Pfad zu Euren Daten eintragen
In [3]:
print(data[:5])
[ 44.14166  48.02898  49.55642  44.14077  42.09511]
In [4]:
plt.hist(data)
plt.xlabel('x / unit')
plt.ylabel('y / unit')
Out[4]:
<matplotlib.text.Text at 0x708c6d8>
In [5]:
plt.hist(data, bins=30) #Zahl der bins auf 30 setzen
plt.xlabel('x / unit')
plt.ylabel('y / unit')
Out[5]:
<matplotlib.text.Text at 0x7375eb8>
In [6]:
plt.hist(data, bins=30, normed=True) #Normierung, Fläche des Histogramms=1
plt.xlabel('x / unit')
plt.ylabel('y / unit')
Out[6]:
<matplotlib.text.Text at 0x7379470>
In [7]:
#Kummulative Verteiling
plt.hist(data, bins=30, normed=True, cumulative=True)
plt.xlabel('x / unit')
plt.ylabel('y / unit')
Out[7]:
<matplotlib.text.Text at 0x7500cf8>
In [8]:
#Mittelwert, Standardabweichung der Verteilung
mean=np.mean(data)
std_dev=np.std(data)
print(mean)
44.8045123731
In [9]:
n, bins, patches=plt.hist(data, bins=30, normed=True)

#Gausskurve in das Histogramm zeichnen
gauss = mlab.normpdf(bins, mean, std_dev)
plt.plot(bins, gauss, 'k', linewidth=2)
Out[9]:
[<matplotlib.lines.Line2D at 0x75f4eb8>]