TLegend *legend = new TLegend(0.6,0.7,0.9,0.9,"legend"); legend->SetTextColor(kBlue); legend->AddEntry(histo,"histogram","L"); legend->Draw();
TLegend *legend = new TLegend(0.6,0.7,0.9,0.9,"legend"); legend->SetTextColor(TColor::GetColor(255, 255, 0)); legend->AddEntry(graph,"graph","L"); legend->Draw();This code creates a legend object, sets the text color to customized color using TColor::GetColor function which takes RGB values as arguments, adds an entry to the legend for a graph, and draws the legend on the canvas. Overall, the TLegend SetTextColor function is a useful tool for customizing the font color of legend text in C++ histograms and graphs created using the ROOT package library.