Specify line color when drawing ttree branches

Hi ROOT Experts,

Is there a simple way to specify line color when drawing ttree branches? In particular, I am drawing ttree branches on the same plot and would like them to be different colors:

tree->Draw(“A”,"","");
tree->Draw(“B”,"",“same”);

Since these aren’t histograms, I can’t set their colors individually with TH1::SetLineColor()

Thanks in advance!
Will

tree->Draw("A"); htemp->SetLineColor(2);

tree->Draw("A", "", ""); // gPad->GetListOfPrimitives()->At(0) ... is a TFrame ((TH1F*)(gPad->GetListOfPrimitives()->At(1)))->SetLineColor(1); // the first "htemp" // gPad->GetListOfPrimitives()->At(2) ... is a TPaveText (the "title") tree->Draw("B", "", "same"); ((TH1F*)(gPad->GetListOfPrimitives()->At(3)))->SetLineColor(3); // the second "htemp" tree->Draw("C", "", "same"); ((TH1F*)(gPad->GetListOfPrimitives()->At(4)))->SetLineColor(4); // the third "htemp" tree->Draw("D", "", "same"); ((TH1F*)(gPad->GetListOfPrimitives()->At(5)))->SetLineColor(5); // the fourth "htemp" gPad->Modified(); gPad->Update(); // make sure the pad is redrawn gPad->GetListOfPrimitives()->Print(); // print what's available

1 Like

Should’n’t it start at 0, so the first primitive is ->At(0) not ->At(1) ?

gPad->GetListOfPrimitives()->Print(); // print what’s available