ROOT Version: 6.15/01
Platform: Ubuntu
I am trying to plot on root using my own C++ code. I do the following (which I got from https://root.cern.ch/doc/master/classTGraph2D.html):
#include <TMath.h>
#include <TGraph2D.h>
#include <TRandom.h>
#include <TStyle.h>
#include <TCanvas.h>
#include <TF2.h>
#include <TH1.h>
int main() {
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; Z 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);
}
gStyle->SetPalette(1);
dt->Draw("surf1");
return 0;
}
The program compiles successfully and runs without problem (Process finished with exit code 0
), however, nothing is plotted.
I tried many other examples unsuccessfully.