LEGO Drawing Fails with TH2Poly


ROOT Version: 6.06/06
Platform: macOS 10.12.6
Compiler: Apple LLVM version 8.1.0 (clang-802.0.42)


Histogram class TH2Poly can only be drawn with option “COLZ”.
It displays an empty histogram if option “LEGO”, “BOX”, “CANDLE”, “CONT” are specified.

Here is an example that allows to reproduce the error. I am using the ROOT provided example “th2polyBoxes.C”, but replacing colz to lego in the argument passed to Draw():

   TCanvas *ch2p2 = new TCanvas("ch2p2","ch2p2",600,400);
   gStyle->SetPalette(57);
   TH2Poly *h2p = new TH2Poly();
   h2p->SetName("Boxes");
   h2p->SetTitle("Boxes");
   Int_t i,j;
   Int_t nx = 40;
   Int_t ny = 40;
   Double_t xval1,yval1,xval2,yval2;
   Double_t dx=0.2, dy=0.1;
   xval1 = 0.;
   xval2 = dx;
   for (i = 0; i<nx; i++) {
      yval1 = 0.;
      yval2 = dy;
      for (j = 0; j<ny; j++) {
         h2p->AddBin(xval1, yval1, xval2, yval2);
         yval1 = yval2;
         yval2 = yval2+yval2*dy;
      }
      xval1 = xval2;
      xval2 = xval2+xval2*dx;
   }
   TRandom ran;
   for (i = 0; i<300000; i++) {
      h2p->Fill(50*ran.Gaus(2.,1), ran.Gaus(2.,1));
   }
   // h2p->Draw("COLZ");
   h2p->Draw("LEGO");
  

3D axes are displayed, but the histogram is flat at zero.

Any suggestion is welcome! Thanks!

void th2polyBoxes() {
   gStyle->SetCanvasPreferGL(true);
   TCanvas *ch2p2 = new TCanvas("ch2p2","ch2p2",600,400);
   gStyle->SetPalette(57);
   TH2Poly *h2p = new TH2Poly();
   h2p->SetName("Boxes");
   h2p->SetTitle("Boxes");

   Int_t i,j;
   Int_t nx = 40;
   Int_t ny = 40;
   Double_t xval1,yval1,xval2,yval2;
   Double_t dx=0.2, dy=0.1;
   xval1 = 0.;
   xval2 = dx;

   for (i = 0; i<nx; i++) {
      yval1 = 0.;
      yval2 = dy;
      for (j = 0; j<ny; j++) {
         h2p->AddBin(xval1, yval1, xval2, yval2);
         yval1 = yval2;
         yval2 = yval2+yval2*dy;
      }
      xval1 = xval2;
      xval2 = xval2+xval2*dx;
   }

   TRandom ran;
   for (i = 0; i<300000; i++) {
      h2p->Fill(50*ran.Gaus(2.,1), ran.Gaus(2.,1));
   }

   h2p->Draw("GLLEGO");
}

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.