TLegend Line Length

Hello all,

I would like to shorten the length of the line used to show the colour of a displayed object (e.g. a TH1D) inside a TLegend. I found TLegendEntry, which has a method .SetMarkerSize(), but this seems to only apply to the point markers of e.g. functions. How can I have shorter, more compact lines inside the legend?

Any help is appreciated. Thanks in advance!
zuiop

{
   TH1F *h1 = new TH1F("h1","h1",100,-10,10);
   h1->FillRandom("gaus",1000);
   h1->SetMarkerStyle(20);
   
   TLegend *leg = new TLegend(0.1,0.5,0.3,0.7);     
   leg->AddEntry(h1,"A gaussian","LEP");
   leg->SetTextFont(62);
   leg->SetTextSize(0.025);
   h1->Draw("histe1");
   leg->Draw();
}

Hi zuiop,

I believe Olivier left out the part that actually answers your question :slight_smile:

I find

leg->SetMargin(0.2); // or some other value)

does what you want.

4 Likes