Dear all,
This is a legend question.
Q1: how to make the legend fill opaque, in a way the plot details (e.g., lines) on which it sits are not visible. I tried different colors, including white, but the legend fill is always transparent.
Q2: how to add a legend entry for the fit curve/line that is returned by FitFunction.cpp in the pseudo code below.
Main.cpp
TH1* h1 = new TH1I("h1", "histo", 100, 0.0, 5.0);
double xmin = 0.1;
double xmax= 4.5;
h1->Draw();
PolFit(h1, polinom, xmin, xmax);
TLegend *legend = new TLegend(0.1, 0.7, 0.5, 0.9);
legend->SetFillColor(0);
legend->AddEntry("h1", "hist", "l");
// ideal: legend->AddEntry("fitted h1", "fit", "l")
legend->Draw();
FunctionFit.cpp
double polinom(double *x, double *par) {
return par[0] + par[1]*x[0] + par[2]*x[0]*x[0];
}
double PolFit(TH1* hist, double x_low, double x_up){
TF1 *fitFunction = new TF1("fitFunction", polinom, x_low, x_up, 3);
hist->Fit("fitFunction");
}
__
Please read tips for efficient and successful posting and posting code
ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided