File: histogram_demo.py

package info (click to toggle)
matplotlib 0.98.1-1%2Blenny4
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 18,624 kB
  • ctags: 22,599
  • sloc: python: 76,915; cpp: 63,459; ansic: 5,353; makefile: 111; sh: 12
file content (23 lines) | stat: -rw-r--r-- 515 bytes parent folder | download
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
import pylab as P

mu, sigma = 100, 15
x = mu + sigma*P.randn(10000)

# the histogram of the data
n, bins, patches = P.hist(x, 50, normed=1)
P.setp(patches, 'facecolor', 'g', 'alpha', 0.75)

# add a 'best fit' line
y = P.normpdf( bins, mu, sigma)
l = P.plot(bins, y, 'r--')
P.setp(l, 'linewidth', 1)

P.xlabel('Smarts')
P.ylabel('Probability')
P.title(r'$\mathrm{Histogram\ of\ IQ:}\ \mu=100,\ \sigma=15$')
P.axis([40, 160, 0, 0.03])
P.grid(True)

#P.savefig('histogram_demo',dpi=72)
P.show()