Home | News | Documentation | Download

TLegend set distance between entry symbol and entry text



I am trying to adjust the distance between an entry symbol (i.e. the marker, line, filled box, etc.) and its text in TLegend independent of its margin (i.e. its width). Is this possible somehow?



What can be set regrading legend geometry is summarise by this example legendgeometry.C (1.4 KB)


Thank you for this clarification. I deduce that it is not possible directly via ROOT. The workaround I am using with pyROOT is

legend = TLegend()
hist = TH1()

entryOption = 'P'
entryTitle = '#kern[-0.2]{ }' + hist.GetTitle()
legend.AddEntry(hist, entryTitle, entryOption)

By adapting the number in the kern, you can adapt the space between the symbol and the text.



Of course the same can be done using C++. For instance:

   auto legend = new TLegend(...);
   auto hist = new TH1(...);
   legend->AddEntry(hist, Form("#kern[-0.2]{ } %s ",hist.GetTitle()), "P");