TLegend text and color

Hi,

is there a possibility to set the color of a legend text?

Thanks,
Maiken

Yes, SetTextColor on the legend itself should work. Shouldn’t it ?

Thank you very much.

I realize I was not specific enough: is it possible to give a single entry text in the legend a colour, and not the whole legend? I would typically like to make a legend with the text entries having different colours.

Thanks a lot,
Maiken

You can also try to apply the same method but on an individual TLegendEntry.

Thank you.

How can I get hold of that specific entry text, and set the colour?

legend.GetEntry().SetTextColor(kBlue)

does for instance not work.

I have tried to understand the class-info of TLegend, but can’t quite get to grips with if this is possible.

Thanks
Maiken

When you add an entry do it this way:

   TLegendEntry* l1 = leg->AddEntry(hpx,"hpx e^{-} #alpha #times","fp");
   l1->SetTextColor(3);

Ah, beautiful. Thank you very much, that is exactly what I needed.

Best wishes,
Maiken