TGraph2DErrors rotation problem with axis position, labels and ticks

Hi all,

I’m working with a TGraph2DErrors and the idea is to use the Z-axis just for the PCOL option. So I’m performing a rotation, but the axis labels and ticks are not behaving has I would expect (depending on the rotation angles Theta and Phi): on the right margin (instead of on the left), on the inner side of the plot or shifted with respect to the origin, overlapping axis title and labels.
The following code produces the image in attachment:

TGraph2DErrors* G2DErr = new TGraph2DErrors(n_points_red);
G2DErr->SetTitle("Plot title; X-axis; Y-axis; Z-axis");
G2DErr->SetName("G2DErr");

for(size_t ii=0;ii<n_points_red;++ii){
    G2DErr->SetPoint(ii,X[ii],Y[ii],Z[ii]);
    G2DErr->SetPointError(ii,Xerr[ii],Yerr[ii],Zerr[ii]);
}

TCanvas* TECanv = new TCanvas("Canv","Canv",800,600);
TECanv->cd();
TECanv->SetRightMargin(0.15);                                                                                                                                 
G2DErr->Draw("err pcol zcol");
TECanv->SetTheta(90);
TECanv->SetPhi(0);
G2DErr->SetMarkerStyle(8);

Am I doing something wrong? Is there the possibility to get a plot that looks like a “simple” TGraphErrors with only two axis and coloured markers?

YvsX.pdf (21.1 KB)

TECanv->SetTheta(90);
TECanv->SetPhi(0.001);

Thank you, it worked!

I have also another problem: on the TGraph2D page it is written that

The axis settings (title, ranges etc …) can be changed accessing the axis via the GetXaxis GetYaxis and GetZaxis methods. They access the histogram axis created at drawing time only. Therefore they should called after the TGraph2D is drawn.

But if I try, for example, to set the label offset, it seems that the command:

G2DErr->GetXaxis()->SetLabelOffset(0.01);

is not effective, even if called after the Draw() command.

it seems to work for me:

{
   TCanvas *c = new TCanvas("c","Graph2D example",0,0,600,400);
   Double_t x, y, z, P = 6.;
   Int_t np = 200;
   TGraph2D *dt = new TGraph2D();
   dt->SetTitle("Graph title; X axis title; Y axis title");
   TRandom *r = new TRandom();
   for (Int_t N=0; N<np; N++) {
      x = 2*P*(r->Rndm(N))-P;
      y = 2*P*(r->Rndm(N))-P;
      z = (sin(x)/x)*(sin(y)/y)+0.2;
      dt->SetPoint(N,x,y,z);
   }
   dt->SetMarkerStyle(20);
   dt->Draw("pcolz");
   dt->GetXaxis()->SetTitle("");
   dt->GetXaxis()->SetLabelColor(kRed);
}

I copy-pasted the code but I obtained the image in attachment. Perhaps it is a problem of ROOT versions, mine is the 5.34/36. I can’t change it because it is on a server.
c.pdf (21.6 KB)

Yes it is. Your version is too old.