Removing 'GRAPH' legend

I have a series of TGraphErrors. They are all declared like this:

TCanvas SherpaLundEffGraph25;
         TGraphErrors *SherpaLundquarkEffGraph25 = new TGraphErrors(numberEntries,quarkEffGraphX,quarkGraphCoordinate25, ey25, ex25);
         SherpaLundquarkEffGraph25->Draw("ACP");
            auto legend3 = new TLegend(0.6,0.7,0.8,0.9);
   legend3->SetHeader("Legend","C"); // option "C" allows to center the header
   legend3->AddEntry(SherpaLundquarkEffGraph25,"SherpaLund 25% Fixed Efficiency","l");
   legend3->Draw();
 gPad->BuildLegend();
        SherpaLundquarkEffGraph25->Write();
        SherpaLundEffGraph25.Print("SherpaLundquarkEffGraph25.pdf");

The first one has just the legend I specify in the code. All subsequent graphs with exactly the same pattern (changing all names for canvas, legend and graph and coordinates) also have a second legend with ‘GRAPH’ in it. How can I remove that?

Thanks for any help :slight_smile:

(also yes I know I have ex and ey the wrong way around, messy fix for a mix up in their declaration)


Please read tips for efficient and successful posting and posting code

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


SherpaLundquarkEffGraph10.pdf (14.7 KB)

Remove: gPad->BuildLegend();

2 Likes

Oh awesome that’s nice and easy! Thanks! :smiley:

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