Hi,
An histogram with bin labels can extend its axis automatically when you set content outside the range.
There is no real meaning anymore for underflow/overflow in this case.
The histogram has therefore its axes automatically extendable. Now, if you don’t want this behaviour
in your first case, you need to call before calling SetBinContent in bib outside the range
h->GetXaxis()->SetCanExtend(false)
In case of Projection, also the overflow are by default include in this case and since you are projecting in a labeled axis, the projection in th overflowed bins is displayed. This explains the doubling of the axis.
If you don’t want to consider the underflow/overflow in the projected Y axis, it is enough to set a range in the TH2 histogram before doing the projection:
h->GetYaxis()->SetRange(1, h2->GetYaxis()->GetNbins() );
If you have a problem with TH1::Add please let me know
Best Regards
Lorenzo