TPad::BuildLegend() Auto Positioning


ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


Hi,

I am trying to use the TPad::BuildLegend() auto positioning feature on a TMultiGraph. Unfortunately the Legend is always built in the bottom left corner as in the example https://root.cern.ch/doc/master/classTMultiGraph.html. Is this a known bug or is there some work around using the gPad? I am on ROOT version 6.12/06.

Cheers
Dom

If you want to have it elsewhere, you need to explicitly define the coordinates.
Of course, you could also “move” it, after it is created / drawn in the “standard” place.

Thanks for the response. Out of curiosity will there be auto-placement implemented in the future? The BuildLegend()'s auto position works nicely with the TH1s.

Cheers
Dom

Can you provide a script showing the issue ? It might be multigraph are ignored.

Hi,

Sorry for the late reply I went on holiday and didn’t have chance beforehand to respond. Here is some example code taken from https://root.cern.ch/doc/master/classTMultiGraph.html and edited slightly. I notice if I draw the last TGraph, as in the example the BuildLegend notices this and move accordingly. If I just add it to the MultiGraph and draw then the BuildLegend is not moved. As you said the MultiGraph is ignored.

Cheers
Dom

ExampleBuildLegend.C (1.2 KB)

Now implemented in ROOT master (also for THStack).
Thanks.

Great! Thank you very much.

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