void overlay() { auto can = new TCanvas("cc", "cc", 400, 50, 1000, 600); auto hpx = new TH1F("hpx", "hpx", 100,-5, 5); hpx->FillRandom("gaus"); hpx->Draw(); can->Update(); Double_t ymax = can->GetFrame()->GetY2(); // Double_t ymax = hpx->GetMaximum(); auto gr = new TGraph(5); Double_t x1 = -1; Double_t x2 = 1; Double_t y1 = 0; Double_t y2 = ymax; gr->SetPoint(0,x1, y1); gr->SetPoint(1,x2, y1); gr->SetPoint(2,x2, y2); gr->SetPoint(3,x1, y2); gr->SetPoint(4,x1, y1); gr->Draw("F"); gr->SetFillColor(kBlue); gr->SetFillStyle(3015); can->Update(); }