ROOT Version: 6
Platform: Windows
Compiler: Ubuntu
I want to write an x-y graph and an x-z graph with x, y, z defined in the following source code. How can I create two TGraphs? As shown in this source code, I defined TGraph twice and tried it, but it didn’t work.
{
int n = 197;
gRandom->SetSeed();
TGraph *g=new TGraph(n);
TGraph *g1=new TGraph(n);
for(int cnt =0.0;cnt<n;){
double x=gRandom->Rndm()*40.0-20.0;
double y=gRandom->Rndm()*40.0-20.0;
double z=gRandom->Rndm()*40.0-20.0;
if((x*x+y*y+z*z)<400.0){
cnt+=1;
g->SetPoint(cnt,x,y);
g1->SetPoint(cnt,x,z);
}
}
g->SetTitle(";x:;y");
g->SetMarkerStyle(20);
g->Draw(“AP”);
g1->SetTitle(";x:;z");
g1->SetMarkerStyle(20);
g1->Draw(“AP”);
}