# How to create a histogram that merges two other histograms

So I have a simple code here that creates two histograms and I am applying them to the same plot axis. Essentially merging both plots in one. I want to be able to create a third histogram that would be defined as a merge of these histograms together. Any ideas on how to do this ? I know how to add two plots but I am not trying to add them and get a new plot but just create a new plot that merges two other histograms together. Hope this makes sense what I am saying.

`````` #include "TH1D.h"

using namespace std;

int hi(){
TH1D *histo1 = new TH1D("myhisto1", "myhisto1",10,0,10);
TH1D *histo2 = new TH1D("myhisto2","myhisto2",10,0,10);

histo1->Fill(7);
histo2->Fill(5);

histo2->SetLineColor(2);
histo1->Draw();

histo2->Draw("same");

return 0;
}
``````

Do you mean adding the bin contents in a 3rd histogram? This can be done with T1H::Add().

``````TH1D *hsum = (TH1D*)histo1->Clone("hsum");
if (! hsum->GetSumw2N()) hsum->Sumw2(kTRUE);
hsum->Draw("hist same");
``````

No I know how to add (+) two histograms but like my example above it merges two plots that even if like if both histograms had a value of 7 so ```
histo1->Fill(7);
histo2->Fill(7);
The bin height does not increase but the two histograms same value just overlap and that’s all does that make sense ?

No, a histogram is a histogram. Moreover, one histogram is one histogram. The same histogram cannot hold two histograms the way you want it to.