How Do I Change Points on a TGraph

Hello, I have TGraph that I want to go through from x=a to x x=b (a,b are constants that don’t matter), and change the y values in a specific way. The only function I saw in the api is TGraph->SetPoint(int i, int x, int y), which requires a point numbers to set the point. However, I get the points through TGraph->Eval(x), and so I don’t know the point index. What is best way to change the point in the graph?



You can do something like:

double a = ...; double b =...; int n = graph->GetN(); double *x = graph->GetX(); double *y = graph->getY(); for (int i=0;i<n;i++) { if (x[i] < a || x[i] > b) continue; //evaluate your new value of x[i] x[i] = ... }


Great, thanks!