TSpline3 axis range


Is there a way to set the axis range for a TSpline3? Right now I do something like (simplified):

TH1Dh = new TH1D(“h”, “h”, 100, -1, 1);
s = new TSpline3(h, “l”, -0.1, 0.1);

I thought -0.1, 0.1 would set the range in the constructor:
root.cern.ch/root/html/TSpline3. … 3:TSpline3

however this does not seem to work. I also do not see a method like TSpline::GetXaxis() that I can use to set the axis range. The strange thing is after I draw, I can select the TAxis so I don’t know which object this belongs to. However after zooming, the TSpline3 is not always redrawn correctly, I get some error like:

“Error in TGraphPainter::PaintGraphHist: X must have N+1 values with option N”

Is there some other way to do this?


You can try this:

   c1 = new TCanvas("c1","A Simple Spline",200,10,700,500);


   const Int_t n = 20;
   Double_t x[n], y[n];
   for (Int_t i=0;i<n;i++) {
     x[i] = i*0.1;
     y[i] = 10*sin(x[i]+0.2);

   TGraph *gr = new TGraph(n,x,y);
   TSpline3 *s3 = new TSpline3("s3",gr);

   s3->Draw("*C SAME");

Thanks a lot, I tried it and it works!