#!/usr/bin/env python # (C) 2000 Huaiyu Zhu <hzhu@users.sourceforge.net>. Licence: GPL # $Id: test_sutils.py,v 1.4 2000/10/05 01:32:27 hzhu Exp $ """ Testing statistics utilities: hist, histplot """ from MatPy.Stats.distribs import randn from MatPy.Stats.utils import hist, histplot from MatPy.gplot import wait if __name__ == "__main__": waittime = None else: waittime = 1 data = randn((300,1)) print "calculating data for histogram" (nn, xx) = hist(data) print nn.T print xx.T print "Default histogram" g = histplot(data, waittime=waittime) g.title("Default Histogram") # Using replot here seems wrong - it tries to find original. Why? # g.replot() # But the hardcopy already contains title, even without replot. g.hardcopy("hist_0.ps") wait(waittime) print "Scaled histogram" histplot(data, waittime=waittime, g=g, scaled=1) print "Histogram with spefied bins" g.title("Histogram with Spefied Bins") g = histplot(data, randn(20).T, waittime=waittime, g=g) g.hardcopy("hist_1.ps")
Result obtained with
>>> from MatPy.tests import test_sutils
calculating data for histogram [ 2 6 23 39 58 61 66 31 12 1 ] [-2.7 -2.13 -1.56 -0.99 -0.42 0.15 0.72 1.29 1.86 2.43 ] Default histogram None Scaled histogram <MatPy.gplot.Gplot instance at 0x8186dfc> Histogram with spefied bins <MatPy.gplot.Gplot instance at 0x8186dfc>