void thsames() { cout << "gStyle->GetOptStat(): " << gStyle->GetOptStat() << endl; TH1F* h1 =new TH1F("h1", "h1", 100, -2, 2); h1->FillRandom("gaus"); h1->FillRandom("gaus"); h1->SetLineColor(kRed); h1->Draw(); h1->Draw(); TH1F* h2 =new TH1F("h2", "h2", 100, -2, 2); h2->FillRandom("gaus"); h2->SetLineColor(kBlue); h2->Draw("sames"); gPad->Modified(); // make sure gPad->Update(); // both hists are drawn TPaveStats *p1 = (TPaveStats*)h1->FindObject("stats"); TPaveStats *p2 = (TPaveStats*)h2->FindObject("stats"); if (p2 == NULL) { cout << "p2 is nullptr!!!!" << endl; } else { p2->Print(); Double_t dy = p2->GetY2NDC() - p2->GetY1NDC(); p2->SetY2NDC(p1->GetY1NDC()); p2->SetY1NDC(p1->GetY1NDC()- dy); gPad->Modified(); gPad->Update(); } }