# Adding fitting parameters to the statistical box in multiple canvas

**URL:** <https://root-forum.cern.ch/t/adding-fitting-parameters-to-the-statistical-box-in-multiple-canvas/42908>\
**Category:** Newbie\
**Created:** [January 1, 2021, 7:10pm UTC](https://root-forum.cern.ch/t/adding-fitting-parameters-to-the-statistical-box-in-multiple-canvas/42908 "2021-01-01T19:10:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![zero1](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/zero1/32/24444_2.png) [@zero1](https://root-forum.cern.ch/u/zero1)\
**Post date:** [January 1, 2021, 7:10pm UTC](https://root-forum.cern.ch/t/adding-fitting-parameters-to-the-statistical-box-in-multiple-canvas/42908/1 "2021-01-01T19:10:03Z")

</div>

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
    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.

---

<div class="post-metadata">

**Author:** ![jalopezg](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jalopezg/32/25844_2.png) [@jalopezg](https://root-forum.cern.ch/u/jalopezg)\
**Post date:** [January 3, 2021, 6:18am UTC](https://root-forum.cern.ch/t/adding-fitting-parameters-to-the-statistical-box-in-multiple-canvas/42908/2 "2021-01-03T06:18:18Z")

</div>

Hi @zero1,

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

Cheers,  
J.

---

<div class="post-metadata">

**Author:** ![dastudillo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dastudillo/32/17280_2.png) [@dastudillo](https://root-forum.cern.ch/u/dastudillo)\
**Post date:** [January 3, 2021, 7:15am UTC](https://root-forum.cern.ch/t/adding-fitting-parameters-to-the-statistical-box-in-multiple-canvas/42908/3 "2021-01-03T07:15:06Z")

</div>

Does it work if you remove this line (or move it above drawing h2\_fit)?

```auto
    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.

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [January 4, 2021, 3:33pm UTC](https://root-forum.cern.ch/t/adding-fitting-parameters-to-the-statistical-box-in-multiple-canvas/42908/4 "2021-01-04T15:33:25Z")

</div>

> [@zero1](#):
>
> click on SetTextAttributes to add the fitting parameters at the statistical box

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 : [ROOT: TPaveStats Class Reference](https://root.cern.ch/doc/master/classTPaveStats.html#PS03)
