Home | News | Documentation | Download

Change the number of significant digits?


Hi, i have created a label on my graphs thanks to options->fit parameters now i want to change the number of digits, how can i do?





I have not created the label from the program but i have put it from the image that i posted before with option->fitparameters .


Moreover i want different number of significant digits in a and Erra, how can i do?


Can you provide a small macro showing what you are Doing ?


The macro is:

ist.C (8.9 KB)

I create the label from this window with option and fit parameter:



I see you create the fits parameter box yourself via:

  TPaveText *r=new TPaveText(0.8,0.8,1,1,"brNDC");

… Why not that’s you choice … and later you fill that box with :

  r->AddText(Form("#chi^{2} / DF = %3.1lf / %1.0lf ",chi2,df));
  r->AddText(Form("Prob = %3.4lf  ",prob));

That’s correct and you have the full control on the number formatting in that case … just adjust the format to have the precision you need.

Note you are not using the option fits …


Yes, this is the metod that i used before but then i have discovered that thanks to option->fit parameters i can create label without TPaveText. Now how can i do with this new method ?


The simplest is to put the following command at the beginning of your macro:



Where ? It gives me error:

ist.C (8.9 KB)

Moreover how can i overcome this problem with TPave:



Here is a version which is working for me. No error.
ist.C (5.8 KB)


It gives me: gstyle undefined identifier.


it is not gstyle but gStyle … (S uppercase). The macro i sent you should work as it is … I just ran it is fine for me.


I have tried your macro and it gives me the same error also with gStyle


I just downloaded it again and ran it and it is fine (with ROOT 5 and ROOT 6). Which ROOT version are you using ? on which machine ? can you copy/paste here the output you get ?


I am using a version of 2012 with visual studio. Anyway i will use Tpave… but how can i overcome this problem :Cattura ?

Thanks :slight_smile:


Even with 2012 version gStyle->SetOptFit(1); should work. This setting has always been there.

Please, can you copy paste here the exact error message you get ?

When I run the last version of the ist.C macro I do not see the plot you are showing.
Can you provide me a version of the macro producing this plot ?


Concerning the first problem i will paste the exact error message when i will turn the language of windows into english.

For the second problem:

ist.C (9.0 KB)

If you look at the last graph you will see only one label but if you try to move it you will discover that there will be four label


Fixed in ist.C (9.0 KB)