2D colz with + & - z numbers = bins with no hits are col

I have filled a TH3D histogram and called

loc3DHist->FitSlicesZ(0,0,0,0,0,25,“LQNR”);

to extract the 2D histogram of the mean. If I understand correctly, this means that it will not fit a mean if there are less than 25 hits in the given x,y bin. Anyway, these means are distributed about zero, so the color axis of the 2D plot spans from 0.02 to -0.02, with green the color for zero. Unfortunately, this makes all of the x,y bins green that either originally had no data or did not have the means fit, swamping the rest of the plot. How do I work around this problem and keep the empty bins white?? Thanks.

  • Paul

With option COL, when a 2D histogram has posivitive contents only, the empty bin are not drawn, they are empty. But when and histogram have negative and positive bins, the bins with 0 content can have been filled and the sum of the weight might be 0. So we do not know if it is a real empty bin or a bin with sum 0. May be we need a new option to force empty bins to not be drawn even if the histogram has negative bins ?

I’m not familiar enough with the histogramming class to know the easiest way around this that would be backwards compatable. It would have to know on a bin-by-bin basis whether or not the content summed to zero or was supposed to be empty.

This is probably a bad idea, but maybe for bins that are supposed to be empty, you could set the bin error to a negative number, such that it knows it’s invalid and won’t draw it. And FitSlicesZ would set that bin error to negative if there were fewer than the minimum number of hits the user specified as the cutoff for calculating the mean. I dunno, but I bet this would have a bunch of unintended consequences though…

In the meantime, Is there a cheap work-around that could work? Right now, I’ve introduced a large manual offset into the z-axis data, such that the mean is never zero. Is there an easy way to override the color axis such that I can manually change the number on the axis that corresponds to the colors? Is there anything else you can think of?

  • Paul

Can you provide me a small example reproducing your problem. I will try to find a solution.

Hi,

I just found this old thread when searching for a solution of about the same problem. Is there now any way of marking bin contents as “invalid - do not draw” (as COLZ)?

For now, my quickfix will be dumping invalid bins into the underflow. Is there a cleaner solution?

(I’m substracting two histograms to compare them. Here, 0-0=0, but most likely caused the limited aperture of our spectrometer. 1E6-1E6=0, too, but that’s an excellent zero with a meaning :slight_smile: I’d like to turn off drawing for all the bins without spectrometer coverage. In the example picture (simulated…) this would be everything with r>0.)


When an histogram is drawn with the option COL, all the none empty bins are painted. If you make sure a bin contains 0, it will not be painted. The concept of “invalid bins” does not exist for a ROOT histograms, so, that cannot be introduced at the painting level. For the COL option it was decided with users after many discussions, that it was better to not paint the empty bins when the histrogam has only positive contain, and to paint them if some of the histogram bins have a negative contain. That is the only “special case” we make for the COL option. Moreover this matches what is done for BOX and SCAT options because empty bins end up with “no drawing” for these options too.