I’ve been plotting THStacks using:
canvas107 = ROOT.TCanvas("c_mc_truth_delta_r_lower", "", 800, 800)
S["mc_truth_delta_r_lower"].Draw("HIST S SAME")
canvas107.Draw()
canvasas['107'] = canvas107
but I can’t get the stats box to appear. Problem is, when I plot the elements of the stack separately, it messes up the plot title, axes labels, and presents the histograms in a way I don’t want. Is it possible to preserve the stack and get the stats box?
Hi @Diracula ,
can you provide a minimal self-contained reproducer for your problem? I’m sure then @couet will be able to help.
Cheers,
Enrico
couet
September 13, 2022, 11:41am
4
have this example:
{
THStack *hs = new THStack("hs", "test");
TH1I *h1 = new TH1I("h1","h1", 3, 1, 4);
TH1I *h2 = new TH1I("h2","h2", 3, 1, 4);
h1->Fill(2);
h2->Fill(2);
h1->Draw();
gPad->Update();
TPaveStats *ps1 = (TPaveStats*)h1->GetListOfFunctions()->FindObject("stats");
ps1->SetX1NDC(0.1);
ps1->SetX2NDC(0.3);
h2->Draw();
gPad->Update();
h1->SetFillColor(kRed);
h1->SetMarkerStyle(21);
h1->SetMarkerColor(kRed);
h2->SetFillColor(kBlue);
h2->SetMarkerStyle(21);
h2->SetMarkerColor(kBlue);
hs->Add(h1);
hs->Add(h2);
hs->Draw();
}