From: Ding Hengtong <dinght_at_iopp.ccnu.edu.cn>

Date: Thu, 20 Apr 2006 21:17:17 +0800 (CST)

Date: Thu, 20 Apr 2006 21:17:17 +0800 (CST)

Thank you very much!

It works well when "lP" option is used.

On Wed, 19 Apr 2006, Rene Brun wrote:

*> Do not use the Draw option "CP" when you have so many points*

*> and use a more optimized algorithm as shown below*

*> *

*> Rene Brun*

*> *

*> *

*> {*

*> gROOT->Reset();*

*> TCanvas *c1 = new TCanvas("c1"," ",200,10,700,500);*

*> TH1F *hr = c1->DrawFrame(0.0001,0.00001,1,100);*

*> c1->SetLogx();*

*> c1->SetLogy();*

*> ifstream my("test.dat");*

*> const Int_t n = 999999;*

*> TGraph *gr = new TGraph(n);*

*> Double_t x, y;*

*> for (Int_t i=0;i<n;i++) {*

*> my >> x >> y;*

*> gr->SetPoint(i,x,y);*

*> }*

*> printf("finished reading data\n");*

*> gr->SetLineWidth(2);*

*> gr->GetXaxis()->SetTitle("x");*

*> gr->GetYaxis()->SetTitle("f(x)");*

*> //gr->Draw("CP");*

*> gr->Draw("lP");*

*> }*

*> *

*> *

*> On Wed, 19 Apr *

*> 2006, Ding Hengtong wrote:*

*> *

*> >*

*> > Hi Rooters,*

*> >*

*> > I want to plot a data file which has 999999 lines, I used*

*> > TGraph class in ROOT but I can't get a figure but just a canvas with*

*> > axis instead.*

*> >*

*> > My code is listed below and according to ROOT Guide, Int_t is 4 Bytes,*

*> > ranges from -2^{31} to 2^{31}-1 and 999999 is actually in this range.*

*> > And I also tried "Long64_t", by which I still can't get the figure I*

*> > wanted. I don't know what's wrong.*

*> >*

*> > {*

*> > gROOT->Reset();*

*> > TCanvas *c1 = new TCanvas("c1"," ",200,10,700,500);*

*> > TH1F *hr = c1->DrawFrame(0.0001,0.00001,1,100);*

*> > c1->SetLogx();*

*> > c1->SetLogy();*

*> > ifstream my("test.dat");*

*> > const Int_t n = 999999;*

*> > Double_t x[n], y[n];*

*> > for (Int_t i=0;i<n;i++) {*

*> > my >> x[i] >> y[i];*

*> > }*

*> > TGraph *gr = new TGraph(n,x,y);*

*> > gr->SetLineWidth(2);*

*> > gr->GetXaxis()->SetTitle("x");*

*> > gr->GetYaxis()->SetTitle("f(x)");*

*> > gr->Draw("CP");*

*> > }*

*> >*

*> > Thanks for any help.*

*> >*

*> > Regards,*

*> >*

*> > Hengtong*

*> >*

*> >*

*> *

-- ************************************************ * Hengtong Ding * * * * Address: Institute of Particle Physics, * * Central China Normal University * * Wuhan, 430079, P. R. China * * Tel: 0086 27 6786 7946 (lab) * * 0086 27 8715 0351 (dormitory) * * Fax: 0086 27 6786 3213 * * Email: dinght_at_iopp.ccnu.edu.cn * * dinghengtong_at_hotmail.com * ************************************************Received on Thu Apr 20 2006 - 15:11:22 MEST

*
This archive was generated by hypermail 2.2.0
: Mon Jan 01 2007 - 16:31:58 MET
*