How to have both histograms in upper pad display error bars with a TRatioPlot

Hi,

When using a TRatioPlot as such:

auto rp = new TRatioPlot(h1,h2);
rp->Draw();

The upper pad plots h1 as a solid histogram, while h2 is plotted as individual points with error bars.

How do I plot h1 as well with error bars? (Ideally as a filled solid area like the Draw(“E3”); option).

I thought that extracting the histogram as such:

h1->SetName("top");
auto rp = new TRatioPlot(h1,h2);
rp->Draw();
TObject* topObject = gr->GetUpperPad()->GetPrimitive("top");                                                                                                                                                                                                                                                                                                                                                                    
TH1F* topGraph = (TH1F*)topObject;                                                                                                                                                                                                                                                                                                                                                                                              
topGraph->Draw("E3 same");

Would work, but it does not. What is the correct way to do this?

Thank you,
Jack

auto rp = new TRatioPlot(h1,h2);
rp->SetH1DrawOpt("E3");
rp->Draw();

Or, if you feel hacky, you may try (I haven’t checked it):

auto rp = new TRatioPlot(h1,h2);
rp->Draw();
rp->GetUpperRefObject()->SetDrawOption("E3");
gPad->Update();

Perfect, thanks very much

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