Hi everyone,
I’m trying two fit three function using three different TGraphErrors and adding them later on a TMultigraph. I don’t want to show the stats box for the third graph (tgC); I just need to draw the function.
I cant’ figure out how I can achieve that.
gStyle->SetOptFit(1111);
TCanvas *tc = new TCanvas("tc","Test",700,500);
TMultiGraph *tm = new TMultiGraph();
TGraphErrors *tgA = new TGraphErrors("file_A.txt");
TF1 * fitA = new TF1("fitA","pol1");
fitA->SetLineColor(kBlue);
tgA->Fit(fitA);
TGraphErrors *tgC = new TGraphErrors("file_C.txt");
TF1 * fitC = new TF1("fitC","pol0");
fitC->SetLineColor(kMagenta); //Want to hide TPaveStats generated from here
tgC->Fit(fitC);
TGraphErrors *tgB = new TGraphErrors("file_B.txt");
TF1 * fitB = new TF1("fitB","pol1");
fitA->SetLineColor(kGreen);
tgB->Fit(fitB);
tm->Add(tgA); tgA->SetTitle("Graph A");
tm->Add(tgB); tgB->SetTitle("Graph B");
tm->Add(tgC); tgC->SetTitle("Graph C");
tm->Draw("AP");
Error in <TGraphErrors::TGraphErrors>: Cannot open file: file_A.txt, TGraphErrors is Zombie
Warning in <Fit>: Fit data is empty
Error in <TGraphErrors::TGraphErrors>: Cannot open file: file_C.txt, TGraphErrors is Zombie
Warning in <Fit>: Fit data is empty
Error in <TGraphErrors::TGraphErrors>: Cannot open file: file_B.txt, TGraphErrors is Zombie
Warning in <Fit>: Fit data is empty
Error in <TGraphPainter::PaintGraph>: illegal number of points (0)
Error in <TGraphPainter::PaintGraph>: illegal number of points (0)
Error in <TGraphPainter::PaintGraph>: illegal number of points (0)
Can you provide something I can run ?
Many Thanks.
tm->Draw("AP");
gPad->Modified(); gPad->Update(); // make sure it's (re)drawn
TPaveStats *s = ((TPaveStats *)(tgC->FindObject("stats")));
if (s) { s->SetX1NDC(-1); s->SetX2NDC(-1); } // get out of sight
gPad->Modified(); gPad->Update(); // make sure it's (re)drawn