How to get graph from a TCanvas

Hi experts,
I have a canvas stored in a .root file.
when I open the root file, I can see a key "KEY: TCanvas can1;1 ".
If I draw the canvas directly using “can1->Draw();”, I would get three graphs. How can I get each graphs from the canvas. I don’t know their primitive names. I show the content of the canvas as following.

root [18] can1->ls()
Canvas Name=can1 Title=CANVAS-SCAN1D Option=
 TCanvas fXlowNDC=0 fYlowNDC=0 fWNDC=1 fHNDC=1 Name= can1 Title= CANVAS-SCAN1D Option=
  OBJ: TList	TList	Doubly linked list : 0
   TFrame  X1= -1.004789 Y1=0.000000 X2=1.004789 Y2=18.000000
   OBJ: TGraph	Exp1D	 : 1 at: 0x563aaec253c0
   OBJ: TGraph	Exp1D	 : 1 at: 0x563aaec4aeb0
   OBJ: TGraph	Exp1D	 : 1 at: 0x563aaec59c50
   TLine  X1=-1.000000 Y1=1.000000 X2=1.000000 Y2=1.000000
   TLine  X1=0.000000 Y1=0.000000 X2=0.000000 Y2=0.000000
   TLine  X1=-1.000000 Y1=3.840000 X2=1.000000 Y2=3.840000
   TLine  X1=0.000000 Y1=0.000000 X2=0.000000 Y2=0.000000
   OBJ: TGraph	Exp1D	 : 0 at: 0x563aaecce1c0
   OBJ: TGraph	Exp1D	 : 1 at: 0x563aaec253c0
   OBJ: TGraph	Exp1D	 : 1 at: 0x563aaec253c0
TGraph *g = (TGraph*)can1->GetListOfPrimitives()->FindObject("Exp1D");

Hi,
Thanks for your suggestion.
There are three graphs. I tried this method, but I can only obtain the first graph.
How can I obtain all of them.
thanks.

Yes they all have the same name … too bad.
May be something similar to what is done in this HowTo can help:

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