Dear experts,
I would like to “highlight” the bin, in a 2D histogram, with the maximum content. i.e. I would like [ROOT] to draw a box around this bin, or add a shading etc…
Do you have any suggestions?
Thank you very much in advance.
Best regards,
Loukas
couet
January 12, 2011, 3:11pm
2
Yes it is always possible to make a small macro doing that.
Which plotting option are you using ?
Hello and thank you for the prompt reply.
I’m using the “TEXT” option [i.e. histo2D->Draw(“TEXT”)]
thank you.
cheers,loukas
couet
January 13, 2011, 9:08am
4
{
TH2D h;
h.SetBins(10,0,10,10,0,10);
h.Fill(1,1,1);
h.Fill(3,3,3);
h.Fill(5,5,5);
h.Draw("TEXT");
// Highlight the maximum
Int_t bin = h.GetMaximumBin();
Int_t binx, biny, binz;
h.GetBinXYZ(bin, binx, biny, binz);
Double_t x1 = h.GetXaxis()->GetBinLowEdge(binx);
Double_t x2 = h.GetXaxis()->GetBinUpEdge(binx);
Double_t y1 = h.GetYaxis()->GetBinLowEdge(biny);
Double_t y2 = h.GetYaxis()->GetBinUpEdge(biny);
TBox b(x1, y1, x2, y2);
b.SetFillStyle(0);
b.SetLineWidth(4);
b.SetLineColor(kRed);
b.Draw();
}
Hello and thank you very much!
It is exactly what I want!
cheers,
loukas