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