Draw THStack with error bars inside canvas

This is great, thank you very much.

Maiken

I had to undo this fix for the time being. It had some bad side effects I just noticed. I should find an other solution.

Oh, that’s not so good, but I have downloaded my own ROOT, so for me it’s ok so far.

When you do find a better fix, you could also for the bottom edge include a bit more space, so that one actually sees the end of the error bar, as one does for the top error bar.

Thanks
Maiken

I know … working on it … The fix was much worst than the bug … and “your bug” is not too serious at the end… and easily bypassed if you draw the frame yourself… so I preferred to revert …

I think I found the solution… but I want to test more this time …

This part of code is to sensitive to be modified. I looked at it closely and found that this line is coming from the frame histogram having all its bins empty. That’s not a line drawn on purpose. The ROOT version we are building now will be use for a long period by LHC experiments and I do not want to include any fix having a such potential of bad side effects now. The amount of various combination is such that it is hardly impossible to test them all. There I prefer to propose you some easy workaround:

{
   TH1D *h1 = new TH1D("h1","h1",10,0,10);
   TH1D *h2 = new TH1D("h2","h2",10,0,10);
   THStack h;

   h1->SetLineColor(kRed);
   h1->SetMarkerStyle(20),
   h2->SetLineColor(kBlue);
   h2->SetMarkerStyle(21);

   for(int i=0; i<11; i++){
      h1->SetBinContent(i,1.5-i/10);
      h1->SetBinError(i,0.5*i);
      h2->SetBinContent(i,10.5-i/10);
      h2->SetBinError(i,0.7*i);
   }

   h.Add(h1);
   h.Add(h2);
   h.Draw("nostack E1");  
   h.GetHistogram()->Draw("0");
   h.Draw("nostack E1 same");
}

You can adjust the minimum adding:

   ....
   h.Draw("nostack E1");  
   TH1D *h3=h.GetHistogram(); 
   Double_t hmin = h3->GetMinimum();
   h3->SetMinimum(hmin+hmin/10.);
   h3->Draw("0");
   h.Draw("nostack E1 same");
   ....