Hi
How would be possible while putting two histograms in the same canvas to fill just the area that is overlapped ?
For example in the attached plot, how can I fill the common area between the “blue” and “red” histos ?
thanks in advance
Alex
Hi
How would be possible while putting two histograms in the same canvas to fill just the area that is overlapped ?
For example in the attached plot, how can I fill the common area between the “blue” and “red” histos ?
thanks in advance
Alex
{
h1 = new TH1F("h1","h1",200,-10,10);
h2 = new TH1F("h2","h2",200,-10,10);
h3 = new TH1F("h3","h3",200,-10,10);
h1->SetLineColor(kRed);
h3->SetFillColor(45);
int i;
for (i=0;i<=10000;i++) {
h1->Fill(gRandom->Gaus(0,1));
h2->Fill(gRandom->Gaus(4,2));
}
Double_t y1, y2, y3;
for (i=1; i<=200; i++) {
y1 = h1->GetBinContent(i);
y2 = h2->GetBinContent(i);
if (y1>0 && y2>0) y3=TMath::Min(y1,y2);
else y3=0;
h3->SetBinContent(i,y3);
}
h1->Draw();
h2->Draw("same");
h3->Draw("same");
}
Instead of an additional histogram you could try to create an additional function: [url]Recreating Convolution Animation on Wikipedia
It might be also interesting to have that area as an histogram for further manipulations.
Thats why I choose that way.