Overlaying two plots from two root files

Hi, This is my snippet

root -l file1.root
[0]fTree1->Draw("fY:fX", "", "")

It draws a 2D plots on canvas c1. I have another file file2.root and I want to do
fTree2->Draw("fY:fX", "", "")
such that both plots are on the same canvas c1. How can I do that?

May be in a macro it is more useful to avoid typing the commands every time you need that plot:

File myplot.C

void myplot() {
   auto f1 = new TFile("file1.root");
   auto f2 = new TFile("file2.root");
   TTree *tree1 = (TTree*) f1->Get("Tree1");
   TTree *tree2 = (TTree*) f1->Get("Tree2");
   tree1->Draw("fY:fX", "", "");
   tree2->Draw("fY:fX", "", "same");
}

Then:

root -l myplot.C

Okay thank you, that works! Is there a way to make them different styles?
Eg: Draw the second as “COLZ”

yes , add the option you need is the 3rd. parameter
“COLZ SAME”

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