Not able to change font size of legend

Hi all,
I am trying to refurbish my fitting plots. A problem that I encounter is to resize the font size of the parameter box. I have:

frame = self.observable.frame()
        data_set = self.proton_ds
        data_set.plotOn(frame)
        model_combined.plotOn(frame)
        model_combined.paramOn(frame,ROOT.RooFit.FillColor(ROOT.kRed),ROOT.RooFit.Label("Global Fit parameters:"),ROOT.RooFit.Layout(0.1, 0.4, 0.9),ROOT.RooFit.Format("NEU", ROOT.RooFit.AutoPrecision(1)),ROOT.RooFit.ShowConstants())
...
frame.Draw()
canvas.SaveAs(canvas_name + ".eps")

I always encounter the problem that the parameter text covers data points and goes out of the box. In the forum I found some hints to change the font size of the parameters with adding:

frame.getAttText.SetTextSize() 

after ‘model.paramOn’

but this didn’t work out for me.
I get the error:

 frame.getAttText.SetTextSize(2)
AttributeError: 'ROOT.MethodProxy' object has no attribute 'SetTextSize'

then I tried to find out if the frame object exists and printed out the pointer. But I get for 'print(frame.getAttText):

<ROOT.TAttText object at 0x(nil)>

as if the object doesn’t exist.
Is there a way to fix this problem? Or do you know another way how to change the font size of the parameter box?

Best Regards and thanks in advance
Tobias Jenegger

Hi @jenegger,

This happens because frame.getAttText is just the function that retrieves the TAttText object, if you want the real object you would have to add parenthesis as in frame.getAttText(). Bu then unfortunately I cannot reproduce this

can you provide a small snippet of code with this issue?
Best,
Vincenzo

Thanks very much for the indirect hint. When I tried to create a snippet of code for you to reproduce the error message I found out that I only get this error if I put the line print (frame.getAttText) after

some_model.plotOn(frame,...

But if I place the code before, it works completely fine and I can resize the font size!
One last question: Do you know, if there is also a way to resize the line spacing, as for now SetTextSize just resizes the font size…

Best Regards
Tobias Jenegger

Dear @jenegger,
I would say that line spacing cannot be customized, according to this post

and the fact that TAttText class doesn’t provide a function to set the line spacing (docs).
Best,
Vincenzo

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