Menu

[r540]: / trunk / htdocs / examples / histogram_demo.py  Maximize  Restore  History

Download this file

24 lines (18 with data), 497 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env python
from matplotlib.matlab import *
mu, sigma = 100, 15
x = mu + sigma*randn(10000)
# the histogram of the data
n, bins, patches = hist(x, 50, normed=1)
set(patches, 'facecolor', 'g', 'alpha', 0.75)
# add a 'best fit' line
y = normpdf( bins, mu, sigma)
l = plot(bins, y, 'r--')
set(l, 'linewidth', 1)
xlabel('Smarts')
ylabel('Probability')
title(r'$\rm{Histogram\ of\ IQ:}\ \mu=100,\ \sigma=15$')
axis([40, 160, 0, 0.03])
grid(True)
#savefig('histogram_demo',dpi=72)
show()
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.