I have saved the results of some code in a TFile as TCanvas (which contains several histograms).
Now I would like to display this results with other histograms.
If I had only histograms I would just divide the main TCanvas (call “mc” below) and plot each histogram in a sub-pad.
Now, since I have a TCanvas as “result” (let’s call it “c”) I tried different approaches:
[ol]
[li] directly print the corresponding TPad of interested via c->GetPad(0), but this creates another TCanvas[/li]
[li] paint the primitives of “c” in the subpad of “mc”. Results in only the border of the pad being drawn.[/li]
[li] I though above “replacing” the subpad by a clone of c->GetPad(0) but don’t know how to do that.[/li][/ol]
May be you should have saved the histograms and not the canvases…
Try to get the the histogram in the canvas and draw it
c1->GetListOfPrimitives()->FindObject(…)
Thank you for the suggestion.
I did not write it in my first post but I did try this method, in a little more complex way since I have more
than an object in my canvas (this is one of the reason I saved the canvas not the object).
For a simple object it works (although I loose the canvas formatting). But for all primitives, it does not work.
Here is the minimal code I used to plot all :
0) start root
1) create two TCanvas c1 and c2
2) save them in the root file f.root
3) quit root
4) re-start root
5) open f.root
6) create the main canvas C
7) divide C in 2 pads
8) draw c1 in the 1st subpad
9) draw c2 in the 2nd subpad