Hi, I am currently working on a plot. I have 1 canvas diveded in 2 plots. For both of the plots I am making a Fit with a function and I would like to add a legend to the canvas adding the 2 graphs and the Fit line as well. For some reason there is no legend on the canvas.
My code looks something like this:
TCanvas * can = new TCanvas(...);
TGraph * f = new TGraph();
TGraph * g = new TGraph();
can->Divide(2,1);
can->cd(1);
... plotting of data ...
TF1 *Fit = new TF1("Fit","[0]/sqrt(x)",0,100000);
f->Fit(Fit);
f->Draw("ALP")
can->cd(2);
... plotting of data ...
g->Fit(Fit);
TLegend *leg = new TLegend(.....);
leg->AddEntry(Fit,"Fit","l");
leg->AddEntry(f,"Error f","lp");
leg->AddEntry(g,"Error g","lp");
leg->Draw();
g->Draw("ALP")
_ROOT Version:_ 6.24/06
_Platform:_ Ubuntu 21.04
_Compiler:_ g++
___