TRatioPlot: Legend with some entries filled, but one as a "p"


I am trying to produce a TRatioPlot between a THStack and TH1F (THStack: MC, TH1F: data). The TH1F is plotted as points, the Stack is a set of filled histograms.

I can make a plot like this:

  auto rp = new TRatioPlot(Eh, data_plot_E);
  rp->GetXaxis()->SetTitle("E_{h} [GeV]");
  rp->GetUpperRefYaxis()->SetTitle("Entries per X GeV");
  TPad *p = rp->GetUpperPad();
  auto leg = p->BuildLegend(0.1,0.7,0.48,0.9, "","f");
  p->Modified(); p->Update();

You will see that I tried adding the data separately which does work, but then I also have an additoinal “data” label in the legend which is an unfilled rectangle. What I want is all the THStack to be filled by the colours (which is working) and the data to be plotted as “p” in the legend. I tried building a TLegend and adding individual entires but it would not plot it (no errors just didnt appear on the plot when drawn)

Please can you help

Please read tips for efficient and successful posting and posting code

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

You macro is not complete and can’t be run. Can you post a running example reproducing your problem ?

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