Hi, I have two 2D TH2 histograms which are plot using h->Draw(“colz”) to color the density of each (x,y) bin. I have one histogram that contains all the data and another histogram that contains a subset of this data. How can I go about using both histograms to plot the ratio of each (x,y) bin in a way similar to colz, e.g. if a particular (x,y) bin in the subset contains 50% of that from the total, then it is coloured 50 (and this colour will range from 0 to 100 as its a percentage).
Try:
h_partial->SetMinimum(h_full->GetMinimum());
h_partial->SetMaximum(h_full->GetMaximum());
Hi, thanks for the answer. I think I need to add a bit more clarity.
It is important that each (x,y) bin density of the partial histogram is divided by the correspinding bin density of the full histogram. For example, if a bin has 50 entries in the partial and 100 entries in the corresponding full, I want its density to be 50 or 50%. If another bin has 5000 in the partial and 10000 in the full, I want the density to also be 50%, and so rescaling alone will not work.
Try:
h_partial->Divide(h_full);
h_partial->SetMinimum(0.);
h_partial->SetMaximum(1.);
and / or:
h_partial->Divide(h_full);
h_partial->Scale(100.);
h_partial->SetMinimum(0.);
h_partial->SetMaximum(100.);
Thank you! That was a lot more straightforward than I anticipated, props to root for its simplicity.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.