TMultiGraph curve determine y co-ordinate from x

Hello everyone,

This is a TMultiGraph curve made up of different sets of data points. I want to determine the exact y coordinate for an already known x coordinate on this curve. For example, what is the value of y for x = 2200 on this curve? Is there any way to do this? Any help is appreciated, thank you!

A TMultiGraph is several TGraphs (“several lines”), not one; you get the values from the graphs, not from the multigraph.
In this case, if you mean the red line, you need to use the graph corresponding to that line. Then you can get the y for a given x with graph->Eval(x), but note that this is interpolated.
If you want the value for one of the actual points that form the graph, you can loop over the points (gr->GetN() to know how many) in the graph with gr->GetPointX(i) to find the i for the x that you want, and then do gr->GetPointY(i) for the corresponding i.
https://root.cern/doc/master/classTGraph.html#a00072523988fdbdee7fa533a678ee27e

Thank you for your prompt reply @dastudillo! I will see if I can do it this way.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.