How can I show stats box, when using THStack?

I have modified your example to generate teh “stat” box for each histogram in the stack at 3 different positions

Rene

void test_stack() {
THStack *hs = new THStack(“hs”, “test”);
TH1F h[3];
for ( Int_t i = 0; i < 3; i++ ) {
h[i] = new TH1F(Form(“h%d”, i), Form(“test h%d”), 50, -5, 5);
h[i]->FillRandom(“gaus”);
h[i]->SetLineColor(2
i+2);
hs->Add(h[i],“sames”);
}
hs->Draw(“ehist nostack”);
//the following lines will force the stats for h[1] and h[2]
//to be drawn at a different position to avoid overlaps
c1->Update(); //to for the generation of the 'stat" boxes
TPaveStats st1 = (TPaveStats)h[1]->GetListOfFunctions()->FindObject(“stats”);
TPaveStats st2 = (TPaveStats)h[2]->GetListOfFunctions()->FindObject(“stats”);
st1->SetX1NDC(.5); st1->SetX2NDC(.7);
st2->SetX1NDC(.2); st2->SetX2NDC(.4);
c1->Modified();
}