Hi,
Fit() does the plot, like Draw(). Put "same" in Fit() and do not Draw the last histo (it will be drawn by Fit())
Ie do:
hist2->Fit("f2","","same",2,150);
instead of:
hist2->Fit("f2","","",2,150);
f2->Draw("same");
Cheers, O.Couet
-----Original Message-----
From: owner-roottalk_at_root.cern.ch [mailto:owner-roottalk_at_root.cern.ch]
On Behalf Of Deepak Kar
Sent: Wednesday, February 20, 2008 2:56 PM
To: roottalk_at_root.cern.ch
Subject: [ROOT] Displaying multiple histograms within same macro
Hi,
I am trying to display 3 different histograms in the same canvas, and
here is what I'm doing in my macro,
{
TCanvas *c1= new TCanvas("c1");
TFile f("../dy_histos/bhel_tlt.root");
TProfile *hist1=(TProfile*)
gDirectory->Get("Ana/dyjet/Hist/dyjet_Tnchg5pairpt2");
//do things with hist1
hist1->Draw();
c1->Update();
TFile f("../dy_histos/ze_gen.root");
TProfile *hist2=(TProfile*)
gDirectory->Get("Ana/dyjet/Hist/dyjet_Tnchg5pairpt2");
// Do things with hist2
hist2->Draw("same");
TF1 *f2 = new
TF1("f2","[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]/x+[5]/(x*x)",0,1000);
f2->SetLineColor(kRed);
hist2->Fit("f2","","",2,150);
f2->Draw("same");
}
It does what it is supposed to do with each histogram, and print hist1, hist2 and f2 individually. However when I run this macro, I end up getting the whatever is drawn last. How can I make it "remember" the eariler histograms? Putting Draw("same") does not help!
Thanks so much,
Deepak
Received on Wed Feb 20 2008 - 15:15:07 CET
This archive was generated by hypermail 2.2.0 : Wed Feb 20 2008 - 17:50:01 CET