TLegend Disappears when I add a TRatioPlot (PyROOT)

Hi!

The solution is to change to the top pad before drawing the legend:

rp.GetUpperPad().cd();
legend.Draw()

As for the different histogram styles, that’s just because the TRatioPlot does that by default (usually people want error bars only for the second histogram). For the first histogram, the default drawing option is "hist", and for the second one it’s "E". But as you already noticed, you can change the style to what you like with SetH1DrawOpt() and SetH2DrawOpt().

PS: see also Creating Legend for Upper Plot in TRatioPlot, where the call to TPad::BuildLegend() implicitly does the cd().

1 Like