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

Skip to content

Commit 6995e54

Browse files
committed
Cleanup and move histogram_demo
1 parent b10a877 commit 6995e54

File tree

2 files changed

+30
-22
lines changed

2 files changed

+30
-22
lines changed

examples/pylab_examples/histogram_demo.py

Lines changed: 0 additions & 22 deletions
This file was deleted.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
"""
2+
Demo of the histogram (hist) function with a few features.
3+
4+
In addition to the basic histogram, this demo shows a few optional features:
5+
6+
* Setting the number of data bins
7+
* The ``normed`` flag, which normalizes bin heights so that the integral of
8+
the histogram is 1. The resulting histogram is a probability density.
9+
* Setting the face color of the bars
10+
* Setting the opacity (alpha value).
11+
12+
"""
13+
import numpy as np
14+
import matplotlib.mlab as mlab
15+
import matplotlib.pyplot as plt
16+
17+
18+
# example data
19+
mu = 100 # mean of distribution
20+
sigma = 15 # standard deviation of distribution
21+
x = mu + sigma * np.random.randn(10000)
22+
23+
num_bins = 50
24+
# the histogram of the data
25+
n, bins, patches = plt.hist(x, num_bins, normed=1, facecolor='green', alpha=0.5)
26+
# add a 'best fit' line
27+
y = mlab.normpdf(bins, mu, sigma)
28+
plt.plot(bins, y, 'r--')
29+
30+
plt.show()

0 commit comments

Comments
 (0)