Text Color from Trace Color


I created a graph with dots as the mode and different colors for the six traces, in creating a legend the marker is very small (dot) and does not provide a sufficient visual clue to the corresponding trace.  I hand coded the text of the label in the trace color, though this is not stable if the underlying trace changes.

It would be nice to have a flag to set the color based on a trace.


You could make a hook function to update the legend that runs every time the graph is updated

Hi Andy

I've run into similar issues, and I agree it would be nice if there was a dynamic link between the legend text color and the trace color.  When I had this issue I wrote a quick script to change the legend colors for me.  You have to add the text color tag to each line in the legend before the script will work, and it assumes that there is only one trace per line in the legend.  I haven't tested it to failure, but it worked well enough in my use cases.

TextBox_Utilities.ipf (5.03 KB)

Note that you can also just set the Symbol Min Thickness in the Symbols tab of the Modify Annotation dialog to make the symbols appear larger in the legend which may avoid this issue. I often increase that size to help distinguish traces.


As an alternative, I agree that the proposed dynamic link between legend text color and trace color would be nice.

I would use a dynamic link like that in tags, if it were available.

"It would be nice to have a flag to set the color based on a trace."

What color would you expect your text to have if the trace color was set to f(z)?

If you change a trace to use f(z) as the color, the marker color in the legend is the last non-f(z) color that was selected.  Maybe duplicate that behavior?

FUNCTION Legend_Fz()

    Make/O/D/N=10 Test_Wave=p
    Display/W=(839,67,1550,635)/K=1 Test_Wave
    ModifyGraph mode=3
    ModifyGraph marker=19
    Legend/C/N=text0/J/F=0/H={20,1,10}/A=MC/X=-39.30/Y=45.26 "\\s(Test_Wave) Test_Wave"
    DoUpdate        //Default trace color is red, legend marker color is also red
    Sleep/S 3
    ModifyGraph rgb=(0,0,0)     //Change trace color to black, legend marker color changes to black
    Sleep/S 3
    ModifyGraph zColor(Test_Wave)={Test_Wave,*,*,Rainbow}       //Change trace color to f(z), legend marker color stays black, even though Rainbow does not have black


You can show the style (including color) for one particular point in the Legend by specifying that point number:

Legend/C/N=text0  "\\s(Test_Wave[0]) Test_Wave"

That can be used to solve the f(z) ambiguity.