Hexagonal bins

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 :neutral_face:

Many thanks!

Yes all the bins are always drawn for a TH2Poly.
May be an option should be added to not draw empty bins.

By the way your histogram does not have empty bins. See the attached picture.


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.

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!

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");
}


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");
}


With option L enabled, the boundaries between empty cells are drawn. I just wondered if that is true for your new method as well.

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 …

My opinion is that it would be more logical. Others may differ. I suppose one could offer both, depending on the difficulty.

I agree with you. I’ll do that.

Done.