Label on the top of my graph

Hi, how can i put this thing on the top of my graph ?

Cattura

Thank you

Hi alberto,
Have a look a the TPaveText class

Cheers
Stefano

Can you be a bit more precise ? what you are showing are the histogram statistics which are automatically displayed when you draw an histogram. What kind of “thing” do you want to put “on top of your graph” ?

i want to put a box in which i can add the information that i want to comunicate about my graph . Following Stefano i was able to create this :

Cattura

But now how can i insert the value of chi square in the box ? (without writing the number).

In order to create this i have used:

TPaveText *r=new TPaveText(0.8,0.8,1,1,“brNDC”);
r->AddText("#chi^{2}= ");
r->Draw();

Thanks

Hi alberto,
use the Form() method, which is basically a printf

Double_t chi2;
... 
Get the chi2
...
r->AddText(Form("#chi^{2}= %lf",chi2));

Cheers,
Stefano

Yes Form is the answer.
Note: if you need only a text (and no frame) you can use TLatex instead of TPaveText

Ok, great:smiley::smiley::smiley::smiley:

Thank you

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.