Hi Ivan,
either add:
gr->Set(10);
or use def ctor:
TGraph *gr = new TGraph();
then points 10 - 60 will go away (yes you extra 50 points at 0)
To see the effect add a line:
cout << gr->GetN() << endl;
Cheers
Otto
On Fri, 5 Nov 2004, Ivan So wrote:
> Hi root folks,
>
> Would someone tell me why I always get one more point at (0, 0) in the
> following code:
>
> // We get one more point at (0, 0). Why?
>
> void zero0 () {
>
> gROOT->Reset();
>
> TCanvas *c1= new TCanvas("c1","Plots",400,10,900,780);
> TGraph *gr = new TGraph(60);
^^
you set number of points to 60!
>
> c1->DrawFrame(-1.2, -1.2, 1.2, 1.2, "10 Points");
>
> gr->SetMarkerColor(kRed);
>
> Float_t px, py;
> const Float_t s = 10.;
>
> for (int i = 0; i < 10; i++) {
> px = TMath::Sin(i / s);
> py = TMath::Cos(i / s);
> gr->SetPoint(i,px,py);
>
> }
> gr->Draw("*");
> c1->Modified();
> c1->Update();
> }
>
> The root version is Version 4.01/02.
>
> Thanks.
>
> Ivan
> so@bnl.gov
>
--
Dr. Otto Schaile Department f"ur Physik, LMU M"unchen
Phone: +49 89 289 14070 Am Coulombwall 1, D-85748 Garching, Germany
Mobil: +49 160 1553598
FAX: +49 89 289 14072 EMail: Otto.Schaile@Physik.Uni-Muenchen.DE
This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:10 MET