The macro producing the previous plot is:
TH2F *spaceabove(TH2F *h, float s, TString ht, int c) {
int nbinx = h->GetNbinsX();
int nbiny = h->GetNbinsY();
float x1 = h->GetXaxis()->GetXmin();
float x2 = h->GetXaxis()->GetXmax();
float y1 = h->GetYaxis()->GetXmin();
float y2 = h->GetYaxis()->GetXmax();
auto hs = new TH2F(ht.Data(), ht.Data(),nbinx, x1, x2, nbiny, y1 , y2);
for (int i=1; i<=nbinx; i++) {
for (int j=1; j<=nbiny; j++) {
hs->SetBinContent(i,j,s-h->GetBinContent(i,j));
}
}
hs->SetFillColor(c);
return hs;
}
void flyinglegoplots() {
Int_t ci = 1756;
auto *c = new TColor(ci, 1., 0., 0.3, "", 0.);
Int_t dark = TColor::GetColorDark(ci);
auto *cd = gROOT->GetColor(dark);
cd->SetAlpha(0.);
printf("dark = %d\n",dark);
THStack *a = new THStack("a","Stacked 2D histograms");
TF2 *f1 = new TF2("f1", "xygaus + xygaus(5) + xylandau(10)",-4,4,-4,4);
Double_t params[] = {130,-1.4,1.8,1.5,1, 150,2,0.5,-2,0.5, 3600,-2,0.7,-3,0.3};
f1->SetParameters(params);
TH2F *h2sta = new TH2F("h2sta","h2sta",20,-4,4,20,-4,4);
h2sta->SetFillColor(38);
h2sta->FillRandom("f1",4000);
TF2 *f2 = new TF2("f2","xygaus + xygaus(5)",-4,4,-4,4);
Double_t params2[] = {100,-1.4,1.9,1.1,2, 80,2,0.7,-2,0.5};
f2->SetParameters(params2);
TH2F *h2stb = new TH2F("h2stb","h2stb",20,-4,4,20,-4,4);
h2stb->SetFillColor(46);
h2stb->FillRandom("f2",3000);
a->Add(h2sta);
a->Add(spaceabove(h2sta, 50, "hs1",ci));
a->Add(h2stb);
a->Draw("lego3");
}