TH3 glbox draw option question

Hello, Rooters,

In my specific problem, I fill a TH3 histogram with different weight for each bin. I have both positive and negative weights. When I draw the TH3 using glbox option, I want to draw red for positive weight bins and blue for negative weight bins. However, I can only find a SetFillColor function for the entire TH3 class. I’ve searched the forum, but can’t find information on my specific problem. Does anyone know how to manipulate different color for each box drawn in TH3 using glbox option? Thanks in advance.

regards,
Hongxuan

In 2D (TH2) we have the possibility to show >0 and <0 bins when an histogram is painted with option BOX. This should be extented to TH3 in the GL case.

I have tried to fill the TH3 with signed weights. There are difference between positive and negative weighted bins. However, the <0 bins are shown not like boxes but thin sheets instead. Although it is useful, I’d much like to have both signed bins shown as boxes.

Lol, in fact it’s an error, it’s a wrongly painted box, I’m fixing it now. The question is how to draw negative bins? Color is bad idea, because color of your hist can be arbitrary, so I canno select “red == positive, blue == negative”. Olivier suggested (and I agree) it should be a shape. May be, I can draw semi-transparent box with minus sign inside :slight_smile: Any ideas?

I just have a thought. There are two options of shapes for the openGL box drawing. One is the regular box with “glbox” option, the other is an ellipse with the “glbox1” option? I think you could use the two shapes. Actually a minus sign inside is also enlighten.

[quote=“tpochep”][quote]
I have tried to fill the TH3 with signed weights. There are difference between positive and negative weighted bins. However, the <0 bins are shown not like boxes but thin sheets instead. Although it is useful, I’d much like to have both signed bins shown as boxes.
[/quote]

Lol, in fact it’s an error, it’s a wrongly painted box, I’m fixing it now. The question is how to draw negative bins? Color is bad idea, because color of your hist can be arbitrary, so I canno select “red == positive, blue == negative”. Olivier suggested (and I agree) it should be a shape. May be, I can draw semi-transparent box with minus sign inside :slight_smile: Any ideas?[/quote]

[quote]I just have a thought. There are two options of shapes for the openGL box drawing. One is the regular box with “glbox” option, the other is an ellipse with the “glbox1” option? I think you could use the two shapes. Actually a minus sign inside is also enlighten.

[/quote]
What about box sizes? Let’s say I have min == -10, and max == 100. What should be the size of negative bin box?
And if I have only negative weights?

The size of box should be set according the absolute value. Ie a “-10 box” has the same size of a “10 box” (that’s how it is done in 2D) but there must be something (different shape) telling that one is <0 and the other >0.

Read my question one more time please. If you have only negative range

[-100, -10] should be -100 bin box be greater in size than -10 or not? If not, how should I select their sizes? Should -100 be zero size, and -10 take the whole bin?

For example, look at how TH2D works (better say “works”) with negative weights (see picture). Weights in hist are from -200 to -10. Should I emulate the same behavior for 3d???

void THistPainter::PaintBoxes(Option_t *)
{
   // Control function to draw a table as a box plot.
   // 
   // For each cell (i,j) a box is drawn.
   // The size of the box is proportional to the absolute value of the cell content.
   // The cells with a negative content draw with a X on top of the boxes.

LOOK AT MY PICTURE. Is this behavior correct or not?

SEND ME THE MACRO

I think we both forgot how to use magic word “please”. Here’s the macro

{
TH2D * hist = new TH2D(“Hist for Olivier”, “Hist for Olivier”, 3, -1., 1., 3, -1., 1.);
hist->SetBinContent(1, 1, -10);
hist->SetBinContent(1, 2, -20);
hist->SetBinContent(1, 3, -30);
hist->SetBinContent(2, 1, -100);
hist->SetBinContent(2, 2, -200);
hist->SetBinContent(2, 3, -300);
hist->SetBinContent(3, 1, -100);
hist->SetBinContent(3, 2, -100);
hist->SetBinContent(3, 3, -100);
hist->Draw(“box”);
}

Yes there is something wrong (I guess). I think the picture should be the same as the one you get with all bin positive except that there is crosses inside. I will have a closer look.

Yes, Olivier, I agree.

What about minus sign on a negative bin box?

I think the color of the minus sign could be a potential problem. For instance, in your demo plot, what if the fill color of the box is red too? Maybe you can use the complementary color to draw the minus sign.

I don’t think so.

I don’t think so.[/quote]

It looks very good. Could you please tell me how to check out the specific codes you have modified for the TH3 gl drawing? I’d like to try for my plots. Thanks in advance!

[quote]
It looks very good. Could you please tell me how to check out the specific codes you have modified for the TH3 gl drawing? I’d like to try for my plots. Thanks in advance![/quote]

I’ll put these changes in SVN head tomorrow