Home | News | Documentation | Download

TLegend with "TMarker"

I could not find the answer for this online in the documentation - I am about half way there but might be doing something “impossible”.

I have a figure onto which I have drawn several "TMarker"s.

I want to create a TLegend object to create a legend for these markers… Please see this screenshot below.

As you can see I have a range of markers on this figure and I wish to put a legend on the left hand side.

This is what I have tried so far:

TMarker *m1 = new TMarker(<X>, <Y>, <markertype>);
...
m1->Draw();
...
TLegend *leg = new TLegend(0.1, 0.5, 0.1, 0.9);
leg->AddEntry(m1, "text", "P");
leg->Draw();

I can see that the legend is (sort of) being drawn as there are 5 points for the markers on the left hand side.

This brings me to question - is what I am attempting to do supported by ROOT? If so, what am I doing incorrectly which causes the legend to be not completely drawn.

It’s ok - I was being stupid.

I accidentally set the second x coordinate for the legend to be the same as the first.

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