29 lines
856 B
Python
29 lines
856 B
Python
import numpy as np
|
|
import matplotlib.pyplot as plt
|
|
|
|
d = np.array([1,0,1,1,2,1,0,0,2,1,1,1,3,0,2,2,1,0,2,3,1,1,2,1,1])
|
|
x, h = np.unique(d, return_counts=True)
|
|
fi = h / h.sum()
|
|
Hi = h.cumsum()
|
|
Fi = fi.cumsum()
|
|
|
|
fig, ax = plt.subplots(2, 1, sharex=True, figsize=(6,6))
|
|
ax[0].bar(x, h, width=0.2)
|
|
ax[0].set_title("Geschwister")
|
|
ax[0].set_ylabel("Absolute Häufigkeit")
|
|
ax[1].bar(x, fi, width=0.2)
|
|
ax[1].set_xlabel("Anzahl Geschwister")
|
|
ax[1].set_ylabel("Relative Häufigkeit")
|
|
fig.tight_layout()
|
|
|
|
fig2, ax2 = plt.subplots(2, 1, sharex=True, figsize=(6,6))
|
|
ax2[0].step(np.r_[x[0], x], np.r_[0, Hi], where="post")
|
|
ax2[0].set_title("Geschwister")
|
|
ax2[0].set_ylabel("Abs. Summenhäufigkeit")
|
|
ax2[1].step(np.r_[x[0], x], np.r_[0, Fi], where="post")
|
|
ax2[1].set_xlabel("Anzahl Geschwister")
|
|
ax2[1].set_ylabel("Rel. Summenhäufigkeit")
|
|
fig2.tight_layout()
|
|
|
|
plt.show()
|