TLegend broken in 5.34/18? bad text alignment

Hi,

In recent Root versions, the text in the TLegend is not aligned anymore with the line illustrating the TGraph that’s being plotted. Is there any workaround?

Cheers
Moritz


[code]{
TCanvas *c1 = new TCanvas(“c1”, “c1”,54,451,800,630);
gStyle->SetOptTitle(0);

TGraph *graph = new TGraph(4);
graph->SetName(“UID84”);
graph->SetTitle(“Graph”);
graph->SetLineWidth(4);
graph->SetPoint(101,3.096641751,-0.01163311115);
graph->SetPoint(102,3.126609252,-0.01163311115);
graph->SetPoint(103,3.141593002,-0.01163311115);
graph->SetPoint(104,3.141593002,-0.02035794337);
graph->Draw(“al”);

TLegend *leg = new TLegend(0.1934673,0.5801047,0.5037688,0.9441536,NULL,“brNDC”);
leg->AddEntry(“UID84”,“leg entry”,“l”);
leg->Draw();
}[/code]

With:

TLegend *leg = new TLegend(0.1934673,0.5813953,0.5037688,0.7043189,NULL,“brNDC”);

It is fine.
I’ll check

Hi,

Yes, when you rescale it it is fine. But I have an automatic script that fills 1 or 2 or any number of entries into a legend. Of course I could write the code that resizes the legend pad on the fly, but I was hoping to avoid that.

Thanks for looking into it!

Moritz

I just committed a fix in both 5.34 and 6.00.
Thanks for reporting.

Hi,
Thanks for fixing! How do I pick it up? Like this?

git clone -b v5-34-00-patches root.cern.ch/git/root.git root-5-34-patch-git
cd root-5-34-patch-git/
git checkout -b v5-34-18 v5-34-18

Cheers
Moritz

I usually to a full clone and checkout the 5.34 version coming with

Hi,

So I tried the patch, and indeed the little test script now renders fine. But unfortunately my production script still has the same problem :frowning: See attached.

Also I noticed that now, when I resize things in the plot, nice yellow arrows appear that indicate the distance to other objects in the plot. I like!

Cheers
Moritz
gammacombo_educationalGgsz_xm_dk.C (61.9 KB)

I’ll check

Distance, size compared to other and alignment :slight_smile: like in tools like PowerPoint or Keynote.

Now fixed in 6.01 and 5.34. The pixel size case was not taken into account.
Thanks for reporting.

Hi,
Now fixed indeed! Thanks!
Moritz