Adding fitting parameters to the statistical box in multiple canvas

I have one macro that creates 4 different canvas, the last two canvas are respectively a canvas with one graph and a canvas with two graph, the code is as follows:

    auto Histogram_canvas_fitted=new TCanvas("Histogram_canvas_fitted","Histogram_canvas_fitted",800,800);
    Histogram_canvas_fitted -> cd(1);
    h2_fit->Draw("lego");
    Histogram_canvas_fitted->Draw();
	auto canvas_xy_fit=new TCanvas("canvas_xy_fit","canvas_xy_fit",800,800);
	canvas_xy_fit->Divide(2);
	canvas_xy_fit->cd(1);projh2X->Draw();
	canvas_xy_fit->cd(2);projh2Y->Draw();

The problem is that when I open the canvas and click on SetTextAttributes to add the fitting parameters at the statistical box it works only for the last two graphs in the last canvas and not for the first one; how can I solve this? Thanks in advance.

Hi @zero1,

I am inviting @eguiraud to this thread. Maybe he can point you in the right direction.

Cheers,
J.

Does it work if you remove this line (or move it above drawing h2_fit)?

    Histogram_canvas_fitted->Draw();

On this line Histogram_canvas_fitted->cd(1), just do cd() instead of cd(1) if this canvas is not divided.

This setting will not allow you to add fitting parameters . It will only act on the text attributes of the stat box.
You better look at : https://root.cern.ch/doc/master/classTPaveStats.html#PS03