Get coordinates of entries in TLegend

Hi,

Hopefully this is the right place to post this question.

I am creating a legend with multiple entries with the “filled” visualization option (“f”) via

leg->AddEntry(h1,"test","f");

It’s straightforward to edit the legend labels and put extra information in them. However, I want to achieve the effect shown in the attachment: I would like to place some numbers inside of the filled markers. Right now, to do that, I am using the coordinates of the legend box and the number of entries in the legend to roughly calculate the coordinates of these filled boxes. This works reasonably (meaning the text doesn’t go outside the boxes) for a few cases, i.e., when there are between 3 and 7 entries in the legend. Is there a more elegant way to do this? Ideally, I would like a way to get the center of these filled boxes so that I can draw text at a specified coordinate rather than roughly calculate it.

Thanks!

Nick


Not Really. There is no such option in TLegend. The best is to have the center of each rectangle and draw the text there with alignment = 22