is there is simple way how to clone only part of histogram? I need to create from 2D histogram a new one keeping only subranges on individual axis. It can of course be done the hard way, ie. create new histogram with new definition of axis and then copy values, but I would also like to automatically keep the labels,title, and style setting. I have tried something along TH2::SetLimits(); TH2::Clone(), but that does not work. The Clone does not take the axis limits into account. Another way would be to Clone the whole histogram and then truncate (cut off) the axis, but I was not able to do that as well although it seems it is possible to expand the axis if needed. I would assume that such a simple functionality must be available somewhere.
thank you for your help. Indeed, that was something I was considering. I can nullify bin content at the beginnings and ends along the axis. However after that I need to “cuf of the axis”, i.e changing number of bins, maximum and minimum. It’s likely my ignorance, but I was not able to find out how to do that.
Let’s say my 2D histogram is TH2D old(“”,“”, 100,0.,500.,100,10.,20.). The x bin width is hence 5 and y binwidth is 0.1 . Now I would like to create(select) a new subhistogram with the same bin sizes and bin content, but restrict axis to values between 100<=x<=200 and 12<=y<=15 like TH2D new(“”,“”,20.,100.,200,30,12.,15.).
I would like to do a thing similar to this (which does not work):
old.GetXAxis()->SetLimit(100.,200.)
old.GetYAxis()->SetLimit(12.,15.)
new=old.Clone();
thank you very much for your help. Indeed I had to resort to this solution. The problem is that I them must manually copy all other histogram properties. It would be very helpful to have such a “range sensitive” clone.