Plotting a histogram
<p>I am trying to plot a histogram with mu and sigma. </p>

<p>Im trying to use the ec_scores values on the y axis, its supposed to show me 0.1 to 1.0
It gives me 1, 2, 3, 4, 5, 6 on the y axis instead. 
Im not getting any errors but this is throwing off the graph completely. Please assist me and tell me what I am doing wrong and how can i get the graph to be generated properly.
Thanks. </p>

<p>This is my code :</p>

<pre><code>import numpy as np

import matplotlib.pyplot as plt

import matplotlib.mlab as mlab

x = np.array([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0])

ec_scores = np.array([1., 1., 1., 0.95923677, 0.94796184, 1., 0.76669558, 1., 0.99913194, 1.])

mu, sigma = (np.mean(ec_scores), np.std(ec_scores))


fig = plt.figure()

ax = fig.add_subplot(111)

n, bins, patches = ax.hist(x, 50, normed=1, facecolor='blue', alpha=0.75)


bincenters = 0.5*(bins[1:]+bins[:-1])

y = mlab.normpdf( bincenters, mu, sigma)

l = ax.plot(bincenters, y, 'r--', linewidth=1)

ax.set_xlabel('Parameters')

ax.set_ylabel('EC scores ')

plt.plot(x, ec_scores)

ax.grid(True)

plt.show()
</code></pre>

<p>Currently the graph looks like this:
<a href="http://i.stack.imgur.com/Kh2jh.png" rel="nofollow"><img src="http://i.stack.imgur.com/Kh2jh.png" alt="enter image description here"></a></p>

<p>As mentioned by @benton in the comments, you can plot the ec_scores as a <a href="http://matplotlib.org/examples/api/barchart_demo.html" rel="nofollow">barchart</a>:</p>

<pre><code>import numpy as np
import matplotlib.pyplot as plt

x = np.array([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0])
ec_scores = np.array([1., 1., 1., 0.95923677, 0.94796184, 1., 0.76669558, 1., 0.99913194, 1.])
mu, sigma = (np.mean(ec_scores), np.std(ec_scores))

fig = plt.figure()
ax = fig.add_subplot(111)
rects = ax.bar(x, ec_scores, width=0.1, align='center', facecolor='blue', alpha=0.75)

ax.set_xlabel('Parameters')
ax.set_ylabel('EC scores ')
ax.grid(True)

plt.show()
</code></pre>

<p>Which will look like this:
<a href="http://i.stack.imgur.com/KHSO6.png" rel="nofollow"><img src="http://i.stack.imgur.com/KHSO6.png" alt="Plotted as a barplot."></a></p>

<p>You can also add error bars by passing an array to the <code>yerr</code> parameter. This is illustrated in the barchart example I linked to above. I am not sure what exactly you are trying to do with normpdf, but the barchart returns a list of rectangles instead of bins, so you might need to adapt this to your code.</p>

<p>I hope this helps.</p>

python matplotlib graph histogram