Hi
I have a problem while using a THStack when I try to draw it by using the “hbar” option.
Here is an example of the kind of code I’m using (first with the “bar” option) :
TCanvas* canvas = new TCanvas("Canvas", "Canvas", 0, 0, 1000, 800);
THStack* stack = new THStack("Stack", "StackTitle");
TH1F* hist1 = new TH1F("Hist1", "Title1", 1, 0, 100);
TH1F* hist2 = new TH1F("Hist2", "Title2", 1, 0, 100);
hist1->SetFillColor(kBlack);
hist2->SetFillColor(kGray);
for(int i = 0; i < 4; ++i)
{
char dataName[50];
sprintf(dataName, "Data%d", i);
hist1->Fill(dataName, 10 + 50*i);
hist2->Fill(dataName, 145 - 40*i);
}
stack->Add(hist1);
stack->Add(hist2);
stack->Draw("nostack,bar");
Here is what I obtain :
Everything works fine here, but in fact, I want the name of my factors on the Y axis, and the value associated on the X axis.
So drawing using the “hbar” option seems to be the best choice for me.
But if I replace the line
stack->Draw(“nostack,bar”);
by
stack->Draw(“nostack,hbar”);
I obtain :
The bars are correct but the labels on X axis and Y axis are mixed together.
(I used the hbar option with a simple TH1F histogram and everything works fine. But as you can see, I can’t make it work with a THStack).
Thanks in advance for your help.