TPaveText and histogram in a same canvas

Hello!

I’m trying to draw a TPaveText and a histogram in the same canvas, but i can’t. When I print the histogram, my TPaveText disappears, and if I draw again in the same canvas of the histogram, it doesn’t appear. I suppose is a simple thing, but I don’t know now how to solve that. I’ve read the User’s guide, I’ve searched at tutorials, and at reference guide, but I haven’t found anything.

Can you help me?

Thanks!

Bye!

Hi,

You can draw your histogram in a canvas and add a TPaveText via toolbar. To do that, show up the toolbar selecting View / Toolbar; click on the ‘pave text’ picture button, then press the left button on the place of the top/left corner, move it and release it on the place of the right/bottom pave text corner. You can add text via context menu - selecting the ‘Insert Text’ entry.

Cheers, Ilka

You should draw your TPaveText AFTER the histogram, otherwise TH1::Draw clears the pad by default

Rene

I’ve tried drawing the TPaveText after drawing histogram but it doesn’t work. What I do is creating the Canvas, then create the TPaveText, then add text to the TPaveText with AddText method, then Draw the histograms, and finally draw the TPaveText with Draw() method. I’ve tried also with a very simple histogram but happens the same. I don’t know if the problem is that the TPaveText that I create is not associated with the histogram. I don’t know how to do that. In the reference guide, I’ve read that the box that is drawn with the histogram at the same time with the mean and the number of entries is associated to a list of functions or something like that.

I don’t know what is the problema, but it doesn’t work. Possibly, the solution will be simple but I don’t know.

Thanks!

Bye!

Could you send the shortest possible RUNNING script reproducing your problem?

Rene

Here is.

I fill a histogram, and not paint his associated TPaveStats, I create my own TPaveText and try to draw but I can’t.
pave.c (275 Bytes)

You have many problems in your script, in particular
-you should use new to create your objects otherwise they will be deleted at exit of your function.
-you must draw your TpaveText in NDC coordinates (default is user coordinate).

See modified script in attachment

Rene
pave.C (329 Bytes)

Thank you very much Rene.

I’ve seen that the problem really was the NDC coordinates. I don’t know exactly why this make impossible to paint the TPaveText, I will read the reference guide to find the answer. Also, I don’t see any difference between option “br” and option “tl”.

But, thank you very much. I have to read again, more slowly the user’s guide.

Thank you!

Without spifying “NDC” you get something on the screen at
the user coordinate 0,8,1 but you see only 2 pixels.

Rene