Re: [ROOT] One Extra Point

From: Rene Brun (brun@pcbrun.cern.ch)
Date: Sat Nov 06 2004 - 15:40:36 MET


I Ivan,

The result is to be expected.
You create a graph with 60 points, but fill only 10.
All the other points are at 0,0 by default.

Rene Brun

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);
> 
>   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
> 



This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:10 MET