Hi Everyone,
When I have two TH2F Histograms plotted on the same pad :
auto *c1 = new TCanvas("c1", "c1",900,900);
gStyle->SetOptStat(0);
gStyle->SetPalette(1);
h2 = new TH2D("h2","",80,-4,12,80,-20,60);
Float_t px, py;
for (Int_t i = 0; i < 25000; i++) {
gRandom->Rannor(px,py);
h2->Fill(px,5*py);
}
h2->Draw("COLZ");
h2a = new TH2D("h2a","",80,-4,12,80,-20,60);
for (Int_t i = 0; i < 25000; i++) {
gRandom->Rannor(px,py);
px += 6.;
py += 8.;
h2a->Fill(px,5*py);
}
h2a->Draw("COL SAME");
It works fine:
Even when the binning is not the same for each TH2F :
auto *c1 = new TCanvas("c1", "c1",900,900);
gStyle->SetOptStat(0);
gStyle->SetPalette(1);
h2 = new TH2D("h2","",80,-4,12,80,-20,60);
Float_t px, py;
for (Int_t i = 0; i < 25000; i++) {
gRandom->Rannor(px,py);
h2->Fill(px,5*py);
}
h2->Draw("COLZ");
h2a = new TH2D("h2a","",40,0,12,40,0,60);
for (Int_t i = 0; i < 25000; i++) {
gRandom->Rannor(px,py);
px += 6.;
py += 8.;
h2a->Fill(px,5*py);
}
h2a->Draw("COL SAME");
c1->Update();
It looks fine for me, but I’m not sure if they are sharing the same Z Scale (color)
However, if I choose not to fill the first histogram:
auto *c1 = new TCanvas("c1", "c1",900,900);
gStyle->SetOptStat(0);
gStyle->SetPalette(1);
h2 = new TH2D("h2","",80,-4,12,80,-20,60);
Float_t px, py;
h2->Draw();
h2a = new TH2D("h2a","",40,0,12,40,0,60);
for (Int_t i = 0; i < 25000; i++) {
gRandom->Rannor(px,py);
px += 6.;
py += 8.;
h2a->Fill(px,5*py);
}
h2a->Draw("COLZ SAME");
c1->Update();
The output is :
I came across this problem in a totally different context, so I wonder if this is the expected behavior when using the option SAME
Thanks a lot,
A.
ROOT Version: 6.13/01
Platform: linuxx8664gcc
Compiler: gcc