mgv4ce
February 7, 2017, 4:18pm
1
Hi experts,
I would like to draw a TH2Poly that is hexagonal. But the empty bins are always drawn. I do
void honeycomb(){
gStyle->SetCanvasPreferGL(true);
TH2Poly *hc = new TH2Poly();
hc->Honeycomb(0,0,.1,25,25);
gStyle->SetPalette(53);
TRandom ran;
for (int i = 0; i<30000; i++) {
hc->Fill(ran.Gaus(2.,1), ran.Gaus(2.,1));
}
hc->Draw("coll");
// hc->Draw("colzlp");
}
Is there something I am missing about the draw options for a TH2Poly?
EDIT: empty bins are alway DRAWN. since obviously empty bins can’t be filled
Many thanks!
couet
February 8, 2017, 8:52am
2
Yes all the bins are always drawn for a TH2Poly.
May be an option should be added to not draw empty bins.
couet
February 8, 2017, 9:10am
3
By the way your histogram does not have empty bins. See the attached picture.
couet
February 8, 2017, 11:38am
4
I just implemented the option “0” (like for lego) to avoid drawing empty bin for TH2Poly drawn wit option col.
It is in the master.
mgv4ce
February 8, 2017, 2:20pm
5
I will check it out soon. Quick question:
I was able to get zero bins to not draw by setting a SetMinimum on Z. But the boundaries (empty hexes) were still drawn. Does the new option prevent these? Could you maybe post what the plot looks like with the new options, and a few empty bins?
Many thanks again!
couet
February 8, 2017, 2:23pm
6
With the new option the following macro gives the attached plot.
I will check what you are saying about setting the minimum.
{
TCanvas *chc = new TCanvas("chc","chc",600,400);
TH2Poly *hc = new TH2Poly();
hc->Honeycomb(0,0,.1,25,25);
hc->SetName("hc");
hc->SetTitle("Option COLZ 0");
TRandom ran;
for (int i = 0; i<300; i++) hc->Fill(ran.Gaus(2.,1), ran.Gaus(2.,1));
hc->Draw("colz 0");
}
couet
February 8, 2017, 2:27pm
7
I tried setting the minimum. The following macros gives the attached plot. Seems ok for me.
{
TCanvas *chc = new TCanvas("chc","chc",600,400);
TH2Poly *hc = new TH2Poly();
hc->Honeycomb(0,0,.1,25,25);
hc->SetName("hc");
hc->SetTitle("Option COLZ and minimum");
TRandom ran;
for (int i = 0; i<300; i++) hc->Fill(ran.Gaus(2.,1), ran.Gaus(2.,1));
hc->SetMinimum(1.);
hc->Draw("colz");
}
mgv4ce
February 8, 2017, 3:11pm
8
With option L enabled, the boundaries between empty cells are drawn. I just wondered if that is true for your new method as well.
couet
February 8, 2017, 3:15pm
9
hc->Draw(“colz L0”);
gives the attached image. do you think it would be more logical to not draw the boundaries of the empty bins ?
I can do that …
mgv4ce
February 8, 2017, 4:12pm
10
My opinion is that it would be more logical. Others may differ. I suppose one could offer both, depending on the difficulty.
couet
February 8, 2017, 4:14pm
11
I agree with you. I’ll do that.