gStyle->SetTitle(0);
gStyle->SetOptTitle(0);
tree->Draw("Vbias:event") ;
TGraph *gr=(TGraph *)gPad->GetListOfPrimitives()->Last() ; gr->SetTitle("Bias vs event");
c1->BuildLegend()
then I always get 2 lines in the legend. The first line contains the argument of Draw, and the second the name I gave to the graph. I guess I do something wrong…
How can I manage to get the legend with just the name I give?
I get also a two lines legend. Which is normal according to the list of primitives in the pad. (see gPad->ls())
BuiLlegend is a completely automatic functionality which creates the legend from the objects in the pad. After a simple Draw of two TTree variables, the frame is drawn with an empty TH2F and the points with a TGraph. You see them in the list. These two objects enter the legend. If you do ntuple->Draw(“px:py”,"",“COL”); you will see only one line in the legend. I will see what can be done in that case.
yes, that might be a way … but in that case you may have to turn off the graphics:
tree->Draw("Vbias:event >> gr ","","goff");
and draw the graph yourself after:
gr->Draw()
Note that depending on the number of lines you need to add, it might be as simple to create the legend yourself (with BuildLegend). root.cern/doc/master/classTLegend.html