Get function from TGraph::Draw("C")


I using root 5.14/00f

I would like to know:

  • which is the interpolation algorithm used by TGraph::Draw with option “C”
  • how can I get the interpolated function, in order to evaluate it at different points

I tried to use TGraph::Eval with spline option to get the function values, but there is a significant disagreement with respect to the curve that is drawn.

Thanks in advance



the algorithm used with option “C” is documented here … aph:Smooth

It is a primitive smoothing algorithm and it is actually not really recommended if you want to do an interpolation.
Therefore there is no possibility to evaluate it at a different point.

For this, I would use a better interpolation algorithm like a spline, which you can evaluate at the point you wish then also draw via TSline::Draw.

Additional interpolation algorithms are also available in the MathMore library, see … ation.html

Best Regards


To complement Lorenzo’s answer, you can use the MathMore reference or TSpline.
I would recommend the class TSpline3 or TSpline3 always available in the ROOT distributions whereas MathMore is not always distributed with teh Core libraries.
Using TSpline3 is straightforward, for example
if you have an existing TGraph* gr

TSpline3 gs("gs",gr); gs.Draw();

Thank you, TSpline is working fine.

I have however one more problem with TGraph: I have a set of four TGraphs and for two of them the last point at x~3 is not drawn. I tried GetXaxis()->SetRangeUser but is not working. I put my code in attach, can you please take a look ?
SigmaPlot.C (1.86 KB)

Just after the canvas creation put:


and remove the option “A” in the first graph drawing ie:


instead of: