Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b75f7eb

Browse files
committed
Added an example for histograms with histtype='step'
svn path=/trunk/matplotlib/; revision=5146
1 parent 7b773fe commit b75f7eb

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

examples/histogram_demo_step.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env python
2+
from pylab import *
3+
4+
mu, sigma = 100, 15
5+
x = mu + sigma*randn(10000)
6+
7+
# the histogram of the data
8+
n, bins, patches = hist(x, 50, normed=1, histtype='step')
9+
setp(patches, 'facecolor', 'g', 'alpha', 0.75)
10+
11+
# add a 'best fit' line
12+
y = normpdf( bins, mu, sigma)
13+
l = plot(bins, y, 'k--', linewidth=1)
14+
15+
16+
# overlay the first histogram with a second one
17+
# were the data has a smaller standard deviation
18+
mu, sigma = 100, 5
19+
x = mu + sigma*randn(10000)
20+
21+
n, bins, patches = hist(x, 50, normed=1, histtype='step')
22+
setp(patches, 'facecolor', 'r', 'alpha', 0.25)
23+
24+
y = normpdf( bins, mu, sigma)
25+
l = plot(bins, y, 'k--', linewidth=1)
26+
27+
axis([40, 160, 0, 0.09])
28+
grid(True)
29+
30+
#savefig('histogram_demo',dpi=72)
31+
show()

0 commit comments

Comments
 (0)