# TLegend set distance between entry symbol and entry text

**URL:** <https://root-forum.cern.ch/t/tlegend-set-distance-between-entry-symbol-and-entry-text/31902>\
**Category:** Newbie\
**Created:** [December 6, 2018, 8:37am UTC](https://root-forum.cern.ch/t/tlegend-set-distance-between-entry-symbol-and-entry-text/31902 "2018-12-06T08:37:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![gollumben](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/g/77aa72/32.png) [@gollumben](https://root-forum.cern.ch/u/gollumben)\
**Post date:** [December 6, 2018, 8:37am UTC](https://root-forum.cern.ch/t/tlegend-set-distance-between-entry-symbol-and-entry-text/31902/1 "2018-12-06T08:37:21Z")

</div>

Hi,

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?

Cheers,  
Ben

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [December 6, 2018, 9:23am UTC](https://root-forum.cern.ch/t/tlegend-set-distance-between-entry-symbol-and-entry-text/31902/2 "2018-12-06T09:23:21Z")

</div>

What can be set regrading legend geometry is summarise by this example [legendgeometry.C](https://root-forum.cern.ch/uploads/default/original/3X/c/5/c5c6f47f9c1fa884508201eadab8662222e2d5af.C) (1.4 KB)

 ![09](https://root-forum.cern.ch/uploads/default/original/3X/d/f/df4f6c53256baac4492f19670f0bcdce267f4658.png)

---

<div class="post-metadata">

**Author:** ![gollumben](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/g/77aa72/32.png) [@gollumben](https://root-forum.cern.ch/u/gollumben)\
**Post date:** [December 6, 2018, 9:55am UTC](https://root-forum.cern.ch/t/tlegend-set-distance-between-entry-symbol-and-entry-text/31902/3 "2018-12-06T09:55:22Z")

</div>

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

```python
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.

Cheers,  
Ben

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [December 6, 2018, 1:18pm UTC](https://root-forum.cern.ch/t/tlegend-set-distance-between-entry-symbol-and-entry-text/31902/4 "2018-12-06T13:18:28Z")

</div>

> [@gollumben](#):
>
> The workaround I am using with pyROOT is …

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

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

```

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [December 20, 2018, 1:18pm UTC](https://root-forum.cern.ch/t/tlegend-set-distance-between-entry-symbol-and-entry-text/31902/5 "2018-12-20T13:18:29Z")

</div>

Closed on December 20, 2018, 1:18pm UTC

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