TH1 Draw option interfere with each other

Hello guys!

I am currently want to plot some histograms together with their pulls. I created a canvas and two pad, and main histograms were draw on pad1 with option “E”, and I wanted to draw the pull plots in pad 2 with option “BAR”, however it seemed that the draw option on pad 2 can not be controlled and no matter what options I gave to it it still plotted with option “E”, quite confusing…

Well I generally have a lot of questions on the plotting control of ROOT when doing several plots on a single canvas, any tips on that?

{
TCanvas *c01 = new TCanvas("c01","",2400,2200);
  c01->cd();
  TPad *p01a = new TPad("p01a","p01a",0.1,0.30,0.9,1.0);
  TPad *p01b = new TPad("p01b","p01b",0.1,0.1,0.9,0.315);
  p01a->Draw();
  p01b->Draw();
  p01a->cd();
  p01a->SetLogy();
  xaxis1 = hist1_1->GetXaxis();
  yaxis1 = hist1_1->GetYaxis();
  xaxis1->SetTitle("pt_{#gamma} (GeV)");
  yaxis1->SetTitle("Entries / 60 GeV");
  yaxis1->SetTitleOffset(1.3);
  yaxis1->SetRangeUser(0.01,1000000);
  hist1_1->Draw("E");

  p01b->cd();
  p01b->SetTopMargin(0.037);
  p01b->SetBottomMargin(0.5);
  xaxis2 = pull->GetXaxis();
  yaxis2 = pull->GetYaxis();
  xaxis2->SetTitle("pt_{#gamma} (GeV)");
  xaxis2->SetTitleOffset(1.25);
  yaxis2->SetTitle("#frac{DATA-MC}{DATA}");
  p01b->SetGrid();
  pull->Draw("BAR");
}

Thanks in advance!

Best,Sebastian

@couet I assume it’s a bug in ROOT. Try with pull->Draw("HIST BAR"); (or you would need to execute pull->Sumw2(kFALSE); but then you lose its errors);

Can you post a macro we can run ?

In a ROOT 6, try (fix “const char *os_X[nx]”):
ROOT 5.34 -> THistPainter -> The bar chart option -> Source

BTW. The same problem appears in ROOT 5, of course. Just try it with “h1b->Sumw2(kTRUE);

This example is now: https://root.cern/doc/master/classTHistPainter.html#HP100
and works as expected.

It’s not about the example.
It’s about the bug that if a histogram has the “sum of squares of weights” then the drawing engine misbehaves and either you “Sumw2(kFALSE)” or you must unconditionally add “HIST” to the drawing flags (even to “BAR”).

Yes you need HIST if Sumw2() is true.
Even with option B

Dear All,

Thanks a lot for the suggestions. Ah yes both methods by setting Sumw2() to false or Draw(“HIST BAR”) work out!

Thanks a lot!

Bestm
Xuli

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