""" -*- python -*- This script demonstrates the creation of a displays with multiple data reps Author: [email protected] $Id: datareps.py,v 1.10 2005/07/30 16:31:57 pfkeb Exp $ """ from load_hippo import app, canvas from hippo import NTupleController # Create NTuple with its's controller. ntc = NTupleController.instance() # # create full path to the file in case this script is not run from this # directory # import sys full_path = sys.path[0] + '/' + 'aptuple.tnt' nt = ntc.createNTuple ( full_path ) from hippo import Display # Create a histogram hist = Display ("Histogram", nt, ('Age', ) ) canvas.addDisplay( hist ) # Overlay another histogram.
""" -*- python -*- This script demonstrates the creation of a displays with multiple data reps Author: [email protected] $Id: datareps.py,v 1.10 2005/07/30 16:31:57 pfkeb Exp $ """ from load_hippo import app, canvas from hippo import NTupleController # Create NTuple with its's controller. ntc = NTupleController.instance() # # create full path to the file in case this script is not run from this # directory # import sys full_path = sys.path[0] + '/' + 'aptuple.tnt' nt = ntc.createNTuple(full_path) from hippo import Display # Create a histogram hist = Display("Histogram", nt, ('Age', )) canvas.addDisplay(hist) # Overlay another histogram.
# Create second static histogram and add it to canvas sthists = Display ( "Static Histogram" ) sthists.setTitle ( "Gaussian Distribution (low statistics)" ) sthists.setLabel ( 'x', 'X' ) sthists.setRange ( 'x', 0, 100) sthists.setBinWidth ( 'x', 1. ) canvas.addDisplay ( sthists ) # Create empty NTuple and set the column label. # Setting the column labels sets the number of columns ntuple = NTuple ( ) ntuple.setTitle ( 'Gaussian Distribution' ) ntuple.setLabels ( ('X value', ) ) # Register the NTuple so the Inspector can see it. NTupleController.instance().registerNTuple ( ntuple ) # Create dynamic histogram and attach it to NTuple. # It will automatically adjust its range, title, and labels dyhist = Display ( "Histogram", ntuple, ('X value', ) ) canvas.addDisplay ( dyhist ) mean = 45 sigma = 10 gauss = random.gauss # Generate some data, fill the static histograms and NTuple. for i in range(10000): x = gauss( mean, sigma ) sthist.addValues ( (x, ) ) ntuple.addRow ( (x, ) )