Trying to control view angle of TGraph2D via script

Greetings all,

I have a script which generates a TGraph2D of a Chi2 surface for individual data runs of a long running series of experiments.

Attached are two PDFs:

  1. The default view that shows up when I draw the TGraph2D to screen that has been labelled Chiplot_ru960309_r01_xyz.pdf

  2. The rotated view that shows just the view at the XY plane of the same data, labelled Chiplot_ru960309_r01_xy.pdf - the rotation has been done manually after the script has finished.

I would like to be to rotate to the XY view via the script, but I can’t seem to figure out how to do it.

I have tried CreateView - but all I seem to do is generate the same view, rather than a different angle.

I have tried ->Project(“xy”) but this does something very different from what I am looking for.

Can someone please point me at the correct method or an example from one of the tutorials where something similar is done.

I seem to be thinking about the problem the wrong way. Any guidance on where I am going wrong will be gratefully received.

Regards
Chiplot_ru960309_r01_t_xy.pdf (40.6 KB)
Chiplot_ru960309_r01_xyz.pdf (43.7 KB)

see example below (see lines with //<======)

Rene

[code]void g2d()
{
TCanvas *c1 = new TCanvas(“c1”);

Double_t rnd, x, y, z;
Double_t e = 0.3;
Int_t nd = 500;

TRandom r;
TF2 f2 = new TF2(“f2”,"1000(([0]sin(x)/x)([1]*sin(y)/y))+400",-6,6,-6,6);
f2->SetParameters(1,1);
TGraph2D *dt = new TGraph2D(nd);

Double_t zmax = 0;
for (Int_t i=0; i<nd; i++) {
f2->GetRandom2(x,y);
rnd = r.Uniform(-e,e);
z = f2->Eval(x,y)*(1+rnd);
if (z>zmax) zmax = z;
dt->SetPoint(i,x,y,z);
}
c1->SetTheta(17); //<========
c1->SetPhi(15); //<========
dt->Draw(“p0”);
}
[/code]

Thank you Rene, that was exactly what I was looking for.