hi,
i’m trying to create a 3d random distribution of points using TGraph, but for some reason it doesn’t generate points for the z axis. here’s the script i’m using,
TCanvas *c1 = new TCanvas("c1","Efficiency",0,0,800,600)
Double_t x,y,z
Double_t j = 100
Double_t k = 4
Int_t n = 100
TGraph2D *dt = new TGraph2D()
TRandom *r = new TRandom()
TRandom *r1 = new TRandom()
TRandom *r2 = new TRandom()
for (Int_t i=0; i<n; i++) {
x = r1->Rndm(i)*k-k;
y = r2->Rndm(i)*k-k;
z = r->Rndm(i)*j-j;
dt->SetPoint(i,x,y,z);
}
gStyle->SetPalette(1)
dt->Draw("surf1")
i’ve tried different variations, but i’m trying to create the plot from random numbers, but all the examples have the graphs set to a predefined function. any advice?
image.ps (204 KB)