Polar Graph Plot

I am trying to plot a polar graph which is basically going to represent angular distribution. But there are about 100 entries for the graph. These entries are saved in a .dat file. Can TGraphPolar take values from a .dat file. If Yes what should be the pattern of values in the .dat file? right now in ang_dist.dat file, I have it as 1st column values of angle (in degress) and second column is radius.

{
   auto c1 = new TCanvas("c1","Polar graph",1500,500);	
   auto pad = new TPad("pad","",0,0,1,1);
   pad->SetGrid();
   pad->Draw();
   pad->cd();
   TGraphPolar * gp = new TGraphPolar ("ang_dist.dat");
   gp-> SetTitle("Angular distribution");
   gp-> SetMarkerStyle(20);
   gp->SetMarkersize(2.0);
   gp->SetMarkerColor(2);
   gp->SetLineWidth(3);
   gp->Draw("PE");
   c1->Update();
   gp->GetPolargram()->SetToRadian();
   
   return c1;
   
}


_ROOT Version: 5.34/36
_Platform: CentOS 7
_Compiler: GCC 4.8.5


TGraphPolar does not have a constructor from a file:
https://root.cern/doc/master/classTGraphPolar.html
What do tis get when you execute your macro ?

I didn’t understand what you meant.
WhenI am executiing my macro I get the following error with an empty canvas

error

Error: Can't call TGraphPolar::TGraphPolar("ang_dist.dat") in current scope trial.c:7:
Possible candidates are...
(in TGraphPolar)
/home/aqsa/Downloads/ROOT/root/lib/libGraf.so  -1:-1   0 public: TGraphPolar TGraphPolar::TGraphPolar(void);
/home/aqsa/Downloads/ROOT/root/lib/libGraf.so  -1:-1   0 public: TGraphPolar TGraphPolar::TGraphPolar(Int_t n,const Double_t* theta=0,const Double_t* r=0,const Double_t* etheta=0,const Double_t* er=0);
/home/aqsa/Downloads/ROOT/root/lib/libGraf.so  -1:-1   0 public: TGraphPolar TGraphPolar::TGraphPolar(const TGraphPolar&);
(in TGraphErrors)
(in TGraph)
*** Interpreter error recovered ***

yes that’s what I mean. TGraphPolar does not have a constructor from a text file.

The answer is “no”.

Okay, I understand. Thank you! :slight_smile:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.