3.6 Profile histograms

Profile histograms are used to show the mean value in each bin of a second variable.

HProf1D histogram class is used to build the profile histograms histograms in one dimension. To disply such histogram on the canvas, use getH1D() method to convert the profile histogram to the usual 1D histogram:

As example, below we calculate the mean values of a Gassian distribution as a function of second variable with uniform random numbers between zero and 10.

from jhplot import *
from java.util import Random

c1 = HPlot("Canvas")
c1.setGTitle("Profile histogram")
c1.setRange(0,11,1.5,2.5)
c1.setNameX("X")
c1.setNameY("Gaussian mean")
c1.visible()

h2=HProf1D("Profile1D",10,0.0, 11.0)
r=Random()
for i in range(2000):
      h2.fill(10*r.nextDouble(),r.nextGaussian()+2)

h1=h2.getH1D()
h1.setStyle('p')
c1.draw(h1)

HProf2D class can be used to build the profile histograms in two dimension, thus one has to pass the number of bins and the minumum and the maximum for X and Y. As before, such histograms represent the mean of some distribution in each bin in X and Y. To display such histogram in the HPlot3D canvas, transform the profile histogram to the usual H2D histogram using getH2D() method.