Legend entry for exclusion graph

In the following minimal example (based on Exclusion graphs in TGraphPainter), the hatch marks are only on one side of the line (a deliberate feature of exclusion graphs), but the legend shows the hatch marks on both sides of the line. Is there a way to have the legend show the hatch marks only on the appropriate side of the line?

exclusiongraphlegend.C (689 Bytes)

exclusiongraphlegend


ROOT Version: 6.12/07 – 6.26/11
Platform: RHEL7
Compiler: GCC 7.3.1 – 12.3.1


Dear @kpedro88 ,

Thanks for reaching out to the forum! I believe @couet will know best here, and if the possibility is not there yet maybe we should add it so that it can better reflect the exclusion graph.

Cheers,
Vincenzo

Thanks for pointing that ! indeed it is implement this way. I.e. the hatches in the legend fill the entire box. I can check if we can improve it.

I have done it. I’ll make a PR

void exclusiongraphlegend() {
   auto gr = new TGraph();
   for (int i=0;i<35;i++) gr->AddPoint(.1*i, 10*cos(.1*i));

   gr->SetLineWidth(-2002);
   gr->SetFillStyle(3004);
   gr->SetFillColor(kBlue);
   gr->Draw("AC");

   TLegend *leg = new TLegend(0.6,0.7,0.8,0.8);
   leg->SetFillColor(0);
   leg->SetBorderSize(0);

   leg->AddEntry(gr,"Exclusion graph","lf");
   leg->Draw();
}

PR here: Exclusion graph legend. by couet · Pull Request #14382 · root-project/root · GitHub

Thanks @couet! This is extremely helpful.

2 Likes

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