TGraph::Draw("C") -> then get points

Dear root expert,

Is the next possible:

  1. I make a graph with only 4 points
  2. I draw the graph with option C to make it smooth
  3. Now I substract the arrays with the “smooth” graph (so with many points, not the original 4)

I want to do this in stead of fitting the points because I don’t know (and don’t care) about the shape the graph should have.

Many thanks in advance,

Ytsen de Boer.

see classes TSpline3 or TSpline5



This spline-thing is not doing the same thing as the “C” option in the graph. It is probably the end point conditions but I have difficulties understanding the meaning of b1, e1, b2 and e2 from the code (maybe some more documentation in the classes’ description).

  1. How do I get TSplineX to do the same as TGraph::Draw(“C”) (couldn’t find that in the code neither, got stuck on AppendPath)

  2. How to substract two arrays with the x and y values (say 1000 points)?

Below is the simplest case of what I did with the result, note that I would like the splines to be as the red line:


// Vectors
Double_t sqrts[4] = { 1., 10., 100., 1000. };
Double_t xsec[4] = { 14.6, 9.55, 14.1, 22. };

// Graph
TGraph * gsx = new TGraph( 4, sqrts, xsec );

// Draw
TCanvas * csx = new TCanvas(“csx”, “csx”, 100, 100, 900, 750);
gsx->Draw(“AC”); // This is the curve I want!

// splines
TSpline5 * sp5 = new TSpline5(“sp5”, gsx);
sp5->Draw(“SAME”); // Ugly

TSpline3 * sp3 = new TSpline3(“sp3”, gsx);
sp3->Draw(“SAME”); // Ugly, identical to sp5


I am looking at your problem again. There is no way, right now, to easily retrieve in vectors the points generated the TGraph::Smooth (the function used by the “C” option). This function receive the arrays to be smoothed as input, smooth them internally and draw the smoothed curve. So the smooted vectors are not visible outside this function. If you really need that functionnality we can try to implement it but that’s not a trivial change, it needs time. Let me know.