in a rootfile, i have a stored TCanvas with a TGraph drawn into it.
How can I retrieve the TGraph, and the vector of Points from the Canvas?
TGraph g1 = (TGraph) c1;
Where c1 is the canvas Didnt work (it didnt cause an error, but all subsequent calls to the TGraph-methods either crash or give 0 as return value.
Thx for the help
If the TGraph is named you can retrieve it with (c1 = pointer to tcanvas):
TGraph * g = (TGraph*)c1->FindObject(name);
(the default name is “Graph”)
(You can give a Graph a name with the SetName(“name”) method)
An array of points in a Graph can be retrieved with GetX() and GetY() and GetN() for the number of points.
You can see what subpads are in a canvas with:
and retrieve certain objects with: