Problem with zero value in the Histo TH2F

I’m sorry,
I have a problem to plot a list of values having “zero” value in a histogram TH2F.
For a Bin with value “0 - Zero” the histo don’t plot the color in the bin.
How can I manage this issue?
Kind regards,
Daniele

Hi Daniele,

In most cases ROOT does not plot 0 values.
In case of color plot it normally ignored. To tweak ROOT histogram painter, you can call:

hpxpy->SetMinimum(-1)

In such case 0 will be not minimum value and will be displayed with the color.

Regards,
Sergey

1 Like

Hi Sergey,
many thanks for your replay,
but in this case with minimum “-1”, I have a blue background because all Hist value = 0 and all Hist value not filled become blu.
I need to “mark” the bin, Lat/Long with “0” in (Blue or how is reported by the color scale), but only for the specific bin and the other must be undefined(White).
Kind regards,
Daniele

Hi Daniele,

If you want to mark only some specific bins, just set content slightly bigger than 0:

h2->SetBinContent(h2->GetBin(20,20), 0.01);

It will be shown with color.

Regards,
Sergey

Hi Sergey,
I already done this approach and works, but my teacher want “0”.
I thank you in advance for your support,
Regards,
Daniele.

There no possibility in ROOT to draw same bin content values with different colors.
Probably, just draw TBox at position you want:

TBox *b = new TBox(-1,-1,1,1);
b->SetFillColor(kBlue);
b->Draw();

We cannot make the difference between bins never filled and bins having content zero because the sum of all fills is zero. Can you provide a small example showing your problem ?

Hi Couet,
I solved the problem with a value 0,00001.
I had to put in an Histogram a set of value where the value of some bin was “0”.
For me “0” is different from no value.
I had a map 12 X 10(BIN), not completely filled, but some of this bin was “0” but for me “0” should be plotted.
For example:
Bin(1,2)=5; Bin(3,5)=3; Bin(2,4)=0; Bin(8,4)=0; Bin(10,6)=0;Bin(1,9)=20; and the other Bin=NULL;
I want to plot the content of Bin(2,4), Bin(8,4) …that are “0” but I don’t want to plot the others BIN=NULL.
If I use the method:
Draw(“COLZ”);
The Bin with value “0” doesn’t appear.
I solved with a value slightly more than 0.
Kind regards,
Daniele

Yes for ROOT value “0” or “not filled” is the same.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.