I have a 2D histrogram:
I need to plot the area that corresponds to a specific value of the 2D integral.
For example I start from the highest point and integrate down and I need to get the contour corresponding to the 95% 2D area and then fill with colour the area corrisponding to the integrated part…
I do have a very involuted home-made way to do it.
However it is not very general and the plotting part doesn’t always work (or it does with very painful ad-hoc fixing).
I wonder if there is a recommended/reliable/builtin way to do it.
or if somebody has a mighty macro he wants to share that does it in a clever way I could not think about
thanks a lot in advance,
We don;t have a general method to do this, but some code exists in the Bayesian tools of RooStats, in the MCMCInterval.cxx (function DetermineByDataHist) and in MCMCIntervalPlot.cxx (DrawHistInterval) to draw the contour corresponding at the desired value.
basically what is done, is sorting the bin content of the histograms and then adding then up until the desired integral value is obtained. The corresponding bin content at the cut off integral value i obtained and from them
one can draw the corresponding contour using the function TH2::SetContour passing the previously obtained contour level.
If you have problem doing this macro, I could eventually write for you. One should do more accurately by using some interpolation/smoothing of the histograms to determine a more precise contour level which is less affected by the bin sizes. I might try to implement such function in the future, since it is useful for obtaining the correct 2D contours from the 2D Bayesian posteriors.
yeah I think that is similar to what i was doing and it is indeed a bayesian analysis I’m performing.
I’ll try to look into those examples to see if they might be better written than what I have and in case follow up with specific problematic cases.
thanks a lot for your reply,