TLegend coloring does not show

I’m trying to make some color lines show in a TLegend by doing this:

l.AddEntry(&vg[i], "name", "l");

where the vector vg[i] contains all of my TGraph. The problem is that the coloring doesn’t show into the final entry.

I’ve tried by subsituting “l” with “p”, because the graphs are of course made of colored points and not lines, but the problem is that the points are so small they barely show on the legend entry.

I can’t seem to find any options to modify the coloring of the entry image without altering the look on the referred function itself.

It would also be really good if the thing could be suitable to be iterated into a for loop (the i in vg[i] is meant to compare multiple tgraphs) but anithing that works is fine

Thanks in advance.


Hi,

probably your problem is that you painted your graphs with markers of different colors, but you never assigned the same colors to the lines of the respective graphs. To do that, just do

for (unsigned int i=0; i<100; ++i) // replace 100 with something meaningful
    &vg[i]->SetLineColor(&vg[i]->GetMarkerColor());
1 Like

it worked, thank you so much