Specifying bin colors in 2D histograms

Hi All,

I’m having trouble trying to specify colors of bins for 2-dimensional histograms. Each bin contains the number either 1, 2, 3 or 4. I want to be able to specify the color that will correspond to the bin contents, e.g. 1=blue, 2=green, etc.

I have created an array called colors[4]={kBlue,kGreen,kRed,kYellow} but am unsure how I assign the colors to the bins. Presently I set the bin contents using:

for( i = 0; i < boxlen; i++ )
for( j = 0; j < boxlen; j++ )
his->SetBinContent( i+1, j+1, grid[i][j]] );

where the array “grid” contains either 1, 2, 3 or 4, and boxlen corresponds to nbin.

The version of ROOT I’m using is 4.00/06.



Hi Jayne,

I think you should use TH1:SetContourLevel feature of ROOT.


see $ROOTSYS/tutorials/multicolor.C in the PRO release 4.00/08