Problem with THStack and "hbar" option

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.

Olivier will fix the problem

Rene

Thank you for your answer.

If it’s a bug, note that I don’t use the last version of Root. I use the version 5.20.00.

I’ll check and let you know. Thanks to have reported it.

I see also the problem with the latest ROOT version. It comes from the method TPad::RedrawAxis() (or some methods called by it) which does not take into account the axis permutation in case of option “hbar”. I am looking at this now.
The following macro is enough to reproduce the problem:

{
   TCanvas* canvas = new TCanvas("Canvas", "Canvas", 0, 0, 500, 500); 
   TH1F* hist1 = new TH1F("Hist1", "Title1", 1, 0, 100);
   hist1->SetFillColor(kGray);
   for (int i = 0; i < 4; ++i) {
      char dataName[50];
      sprintf(dataName, "Data%d", i);
      hist1->Fill(dataName, 10 + 50*i);
   }
   hist1->Draw("hbar");
   gPad->RedrawAxis();
}

This problem is now fixed in the svn trunk.
Thanks for the report.