Set styles for multiple Fit boxes

I have 4 TGraphErrors which I’m drawing on the same canvas with:

ge1->Draw("AP*");
ge2->Draw("Psame");
etc.

I then set their marker colours and line colours so that they’re distinguishable, I fit them all using:

ge1->Fit("pol1");
ge2->Fit("pol2");
etc.

and I show the fit parameters using gStyle->SetOptFit(0001); which puts all of the fit boxes on top of each other. I would like to get access to each individual fit box in order to set its coordinates and line/text colours. From the TPaveStats class reference it seems that the stats box is considered a property of the canvas, so how can I get access to each stats box in turn?

I realised you can get the stats box directly from the graph after having set the gStyle:

TCanvas *c1 = new TCanvas("c1","c1",900,900);
ge1->Draw("AP*");
ge2->Draw("Psame");

ge1->Fit("pol1");
ge2->Fit("pol1");

gStyle->SetOptFit(0001);

TPaveStats *Stats1 = (TPaveStats*)ge1->FindObject("stats");
TPaveStats *Stats2 = (TPaveStats*)ge2->FindObject("stats");

Stats1->SetLineColor(2);
Stats2->SetLineColor(4);

Stats1->SetTextColor(2);
Stats2->SetTextColor(4);

c1->Modified();
c1->Update();

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