Main.Histograms History

Hide minor edits - Show changes to markup

May 04, 2010, at 02:50 PM MST by 10.84.44.105 -
Added lines 1-34:

(:source lang=python:)

""" Make a histogram of normally distributed random numbers simplified version of http://matplotlib.sourceforge.net/examples/api/histogram_demo.html """ import numpy as np import matplotlib.pyplot as plt

  1. create data with normal distribution with given mean and standard deviation

mu = 100 sigma = 15 x = mu + sigma * np.random.randn(10000)

fig = plt.figure() ax = fig.add_subplot(111)

  1. the histogram of the data

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

ax.set_xlabel('Smarts') ax.set_ylabel('Probability')

  1. set the x and y limits
  2. ax.set_xlim(40, 160)
  3. ax.set_ylim(0, 0.03)
  4. show grid-lines

ax.grid(True)

fig.show()

(:sourceend:)