polluxx
February 24, 2010, 6:16am
1
Hello.
I am having problems plotting a scaled histogram (including a fit) without error bars.
Reading through the Root Talk posts, the draw option “hist” should be used.
So:
histo->Sumw2();
histo->Scale(x);
histo->Draw("hist");
histo->Fit("gaus");
should do the job. It however doesn’t seem to work.
A minimal example is attached, it would be great if somebody could have a look.
Maurits
test.cxx (337 Bytes)
couet
February 24, 2010, 9:18am
2
int test() {
TH1D *histo = new TH1D("histo","Random Gauss",1000,-4,4);
for (int i=0; i<10000; i++)
histo->Fill(gRandom->Gaus(0,1));
histo->Sumw2();
histo->Scale(1.e-5);
histo->Rebin(4);
histo->SetFillStyle(3004);
histo->SetFillColor(4);
histo->Fit("gaus","Q");
histo->Draw("hist");
TF1 *g=histo->GetListOfFunctions()->FindObject("gaus");
g->Draw("same");
}
polluxx
February 25, 2010, 11:21am
3
Thank you, that does the job.
The culprit seems to be
which seems to reset any Draw(“hist”) option. Peculiar…
Cheers,
Maurits