<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">
I spent a little time playing around with the Python statistical graphing library MatPlotLib this evening. I've attached a screenshot of a demo histogram and, below, the code needed to create it. This example uses TkInter, but it isn't much more complicated to put this into wxPython. This seems pretty cool. There are much nicer plots too.<div><br class="webkit-block-placeholder"></div><div>Michael<br><br><div> <span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: normal normal normal 12px/normal Helvetica; ">____________________</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: normal normal normal 12px/normal Helvetica; ">C. Michael Barton, Professor of Anthropology</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Director of Graduate Studies</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: normal normal normal 12px/normal Helvetica; ">School of Human Evolution & Social Change</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Center for Social Dynamics & Complexity</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: normal normal normal 12px/normal Helvetica; ">Arizona State University</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: normal normal normal 12px/normal Helvetica; ">Phone: 480-965-6262</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: normal normal normal 12px/normal Helvetica; ">Fax: 480-965-7671</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: normal normal normal 12px/normal Helvetica; ">www: <<a href="http://www.public.asu.edu/~cmbarton">www.public.asu.edu/~cmbarton</a>></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br class="webkit-block-placeholder"></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br class="webkit-block-placeholder"></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">======== example code =======</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br class="webkit-block-placeholder"></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><div>#!/usr/bin/env python</div><div>from pylab import *</div><div><br class="webkit-block-placeholder"></div><div>mu, sigma = 100, 15</div><div>x = mu + sigma*randn(10000)</div><div><br class="webkit-block-placeholder"></div><div># the histogram of the data</div><div>n, bins, patches = hist(x, 50, normed=1)</div><div>setp(patches, 'facecolor', 'g', 'alpha', 0.75)</div><div><br class="webkit-block-placeholder"></div><div># add a 'best fit' line</div><div>y = normpdf( bins, mu, sigma)</div><div>l = plot(bins, y, 'r--')</div><div>setp(l, 'linewidth', 1)</div><div><br class="webkit-block-placeholder"></div><div>xlabel('Smarts')</div><div>ylabel('Probability')</div><div>title(r'$\mathrm{Histogram\ of\ IQ:}\ \mu=100,\ \sigma=15$')</div><div>axis([40, 160, 0, 0.03])</div><div>grid(True)</div><div><br class="webkit-block-placeholder"></div><div>#savefig('histogram_demo',dpi=72)</div><div>show()</div><div><br class="webkit-block-placeholder"></div><div><br class="webkit-block-placeholder"></div><div>===== graph generated by this code ===========</div><div><br class="webkit-block-placeholder"></div><div><br class="webkit-block-placeholder"></div></div></div></span><br class="Apple-interchange-newline"></span><img src="cid:1E440869-E0F3-4EA2-AA7A-AA399C1BE9AE@domain.actdsltmp"> </div><br></div></body></html>