Top view with "lego2z" option

Hi rooters

I would like to have a top view of a 2D histo drawn with “lego2z” option. Right now, after drawing, I right click on the pad on the “TView3D” object and select “Top”.
How can I do this in a script? I don’t know how to get the “TView3D” object from the pad. I have probably to do something like : “gPad->GetView()” and apply the “Top” method on it. But right now the “TView” pointer returned by the
gPad->GetView() command is zéro.

Thanks.

You should used the COLZ option seems to me …

Hi Olivier

There is a small difference using “colz” option: cells borders are not drawn whereas they are when using “lego2z” and “Top”. That’s why I prefer the second method.
Except if there is an option to draw cells’s borders with the “colz” option.

Thanks

Ah, I see… seeing the LEGO2 from top will give you bad axis … I think border with COLZ would be better. I will come with something…

try this:

grid4() 
{
   hpxpy->Draw("COL");
   drawgrid(hpxpy);
} 
 
drawgrid (TH2* h)
{
   Int_t nx    = h->GetNbinsX(); 
   Int_t ny    = h->GetNbinsY();
   Double_t x1 = hpxpy->GetXaxis()->GetXmin();
   Double_t x2 = hpxpy->GetXaxis()->GetXmax();
   Double_t y1 = hpxpy->GetYaxis()->GetXmin();
   Double_t y2 = hpxpy->GetYaxis()->GetXmax();
   Double_t x=x1;
   Double_t y=y1;

   TLine l; 

   for (int i=0; i<nx; i++) {
      l.DrawLine(x,y1,x,y2);   
      x = x+hpxpy->GetXaxis()->GetBinWidth(i);
   }
   for (int j=0; j<ny; j++) {
      l.DrawLine(x1,y,x2,y); 
      y = y+hpxpy->GetYaxis()->GetBinWidth(j);
   }
}

Hi Oliver

Thanks for your answer. It is exactly what I want.

But why did you say “the LEGO2 from top will give you bad axis”? I also managed to do ths in a script using rotations (c is the canvas)

c->SetTheta(90);
c->SetPhi(-360);

Because they are the axis 3d seen from top. The ticks are on the wrong side, and cannot be changed … etc… that’s details really. The axis labels are correct.