I am trying to fit two histogram with two PDF curves using the following code (from Fitting a histogram with python):
datos_A = df['KWH/hh (per half hour) ']
datos_B = df['Response KWH/hh (per half hour) ']
(mu_A, sigma_A) = norm.fit(datos_A)
(mu_B, sigma_B) = norm.fit(datos_B)
n, bins, patches = plt.hist([datos_A , datos_B], 16, normed=1)
y_A = mlab.normpdf(bins, mu_A, sigma_A)
y_B = mlab.normpdf(bins, mu_B, sigma_B)
l = plt.plot([bins, bins], [y_A, y_B], 'r--', linewidth=2)
plt.grid(True)
plt.show()
However, I get something like this:
Instead of two PDF lines for each histogram, I get those vertical lines. I have tried to fix this in many ways but I still cannot figure it out.
After adjusting my code I am getting this two lines, however, they are not smooth curves.