Drawing TH2 with COLZ

Hi,

I have a couple of questions about drawing a TH2 histogram with the ‘colz’ option (I am using the ROOT version 5.10.00d). I apologize if the questions have already been asked and answered somewhere else, but I didn’t find anything in connection with them, neither on the forum nor in the ROOT’s documentation. Also, I have attached a small cxx file and a Makefile to this message (see the .tar file) to help me explain better the situations presented below. So, here they are:

  1. if all the bins of a TH2 histogram are filled with the same value, then when drawing the histogram with ‘colz’ in a canvas a ‘white histogram’ is displayed such that, without the number of entries in the statistics box one could think the histogram is empty. As a consequence (I guess!) the color palette is not anymore drawn. If the same histogram (with the same content) is drawn this time with the ‘lego2’ option, then a ‘non-white’ x-y plane is displayed at the height (z) given by the constant entry in each bin (in my example z=50). Which means that now one has a better information/picture about the non-empty status of the histogram. My question is: if I am constrained to use ‘colz’, is there any option/setting which could allow me to draw non-white bins for such cases (and consequently enable the color palette) ?

  2. is it possible to draw borders for each box/cell (or for a cluster of cells) ? What I’m trying to do/get is a kind of combination between the ‘box’ and ‘colz’ options, keeping the cell size constant (i.e. equal with the size of the bin) and only varying the color of the cell with the bin content. I’ve tried several things, including combinations between different drawing options as well as applying different drawing style options, but I wasn’t successful.

Many thanks in advance!

Cheers,
Victor.
example_TH2.tar (10 KB)

What would you expect ? all the bins are the same so they are all the same color. What would you like to see ? I cannot think of an other representation

Hi,

firstly, thanks a lot for your reply!

That’s fine for me, it’s what I’m expecting.

Well, I would prefer to colour the bins with anything else, but not white. In my opinion, white is misleading because it’s also the color used to represent empty bins/histograms. Therefore, if I get a ‘white histogram’, I always have to check the number of entries in order to distinguish between an empty histogram and a histogram with same content in each bin. If the latter is produced by a monitoring tool during the experiment, and its content is updated periodically, I might not have always the time to perform this check. That’s why I would prefer to draw the bins with a different color than white (of course, the same for each bin). And the color can be, for example, the maximum value of the color palette, or simply any other color. By the way, when drawing the same histogram with ‘lego2’, all the bins are coloured in green. If I change the color palette, then the color of the plane changes. So there must be an algorithm which says, if all bins have the same content, then draw them with a certain color, which seems to be dependend on the palette used. So, is it possible to have the same effect for “colz” ?

And one more thing, sorry for being too insistent: is there any solution for point 2 ?

Cheers,
Victor.

Right now the method painting the COL option has explicitly the following code:

   Double_t dz = zmax - zmin;                                                                            
   if (dz <= 0) return;

Your histogram enter this case. It is always possible to change this behavior but this code has been this way since, at least, May 2000 when ROOT was first introduced in CVS. Therefore there are serious backward compatibility issues to consider.

For point 2 you can do something like:

h->Draw("col");
h->Draw("box same")