Pylab

From Rizzo_Lab
Revision as of 16:50, 11 September 2009 by Stonybrook (talk | contribs)
(diff) ←Older revision | view current revision (diff) | Newer revision→ (diff)
Jump to: navigation, search

Plotting a histogram

from matplotlib.figure import Figure
from matplotlib.backends.backend_agg import FigureCanvasAgg
from pylab import randn 

x = randn(10000)
fig = Figure(figsize=(10,10))
ax = fig.add_subplot(111)
ax.hist(x,100)
ax.set_xlabel("Random Numbers")
ax.set_ylabel("Population")
canvas = FigureCanvasAgg(fig)
canvas.print_figure("hist.png", dpi=300)