To load a file and plot with TH2F

Hi all,

I have a data file .dat with three columns, I want to plot the data using TH2F *h3 new TH2F( ), and filling:

h3->(First_column,Second_column, Third_column)

But, I don’t know how to load the file.

I would like your help…

Thank you for your attention.

Manuel

I suggest:

TNtuple nt("nt","test","x:y:z"); nt.Read("myfile.dat"); nt.Draw("x:y:z");

Rene

I tried with your suggestion:

void Histo()
{
   
    TCanvas *c1=new TCanvas("c1","Evolucion",200,50,700,500);

   c1->SetFillColor(30);
 TNtuple nt("nt","test","x:y:z");
   nt.Read("resultado.dat");
 nt.Draw("x:y:z");
}

But, the script is not plotting anything.

void Histo() { TCanvas *c1=new TCanvas("c1","Evolucion",200,50,700,500); c1->SetFillColor(30); TNtuple nt("nt","test","x:y:z"); nt.ReadFile("resultado.dat"); //<=== ReadFile not Read nt.Draw("x:y:z"); }

Thanks Couet, your suggestion worked.

The graph generated is different from the graphic that I want, I want the type de graph gerated for TH2F using Draw(“surf1”).

Any way to do this??

Thanks

nt.Draw("x:y","z","surf1"); 

See the help:
root.cern.ch/root/html/TTree.html#TTree:Draw