TLegend in .py script

Dear Experts,

     I have .py script to make my plot in ROOT.  I have these lines in my script:

legend = TLegend(.44,.72,.74,.95)
legend.AddEntry(graph_1,"| #eta | < 1.0",“lp”)

Everything works fine but I do not get the latex symbol for #eta in the legend. I thought latex symbol could be defined in TLegend(?)


best regards,

It works in a C macro. It must be a Python issue. I move this post to the Python forum.


yes, could be.

Does anything show up at all? I.e. are you only missing the eta symbol, or is the full TLegend not there? If the latter, make sure that it’s lifetime is not curtailed by the scope you put it in, e.g. by adding it as a data member to the TCanvas to which it belongs.


Thanks for your reply.

Legend shows up and everything is fine except the eta symbol. It showsl ike this “#eta” in the legend.


just to confirm it is fine with C:

root [0] legend = TLegend(.44,.72,.74,.95)
root [1] legend.AddEntry(hpx,"| #eta | < 1.0","lp")
root [2] legend.Draw()

gives the attached plot

could someone please give a very small example of python where this works.


from ROOT import TLegend, TH1D
hpx = TH1D()
legend = TLegend(.44,.72,.74,.95)
legend.AddEntry(hpx,"| #eta | < 1.0","lp")