Re: How to get a polyline from a TGraph?

From: Rene Brun <Rene.Brun_at_cern.ch>
Date: Fri, 16 Feb 2007 13:17:32 +0100


Hi Nico,

I suggest TGraph::Eval to compute a linear interpolation between points or a spline interpolation.
If you have a TGraph *g, you can make a spline with

   TSpline3 *s = new TSpline3("s",g);
   g->Draw("alp");
   s->Draw("same");

or compute an interpolated value for any x position with s->Eval(x);

Rene Brun

Nico De Simone wrote:
> Dear Rooters,
> my problem is to get a polyline function made from linear
> interpolation of many (x,y) points, that is starting from two arrays
> Double_t x[] and Double_t y[].
>
> I'm able to do it writing my how function and using TF1("myfnc",
> myfcn, xmin, xmax, npar) but I cannot use it as a class member.
>
> Using a TGraph Draw("APL") I see the polyline,
> gROOT->GetListOfFuncion()->Print() shows a lot of functions but I
> don't know I to use them.
>
> I will be grateful if you could suggest me a proper way to do it.
>
> Cheers,
> Nico
>
Received on Fri Feb 16 2007 - 13:17:38 CET

This archive was generated by hypermail 2.2.0 : Fri Feb 16 2007 - 23:50:01 CET