4.9 FAQ-368 How do I modify the graph legend using LabTalk?

Last Update: 8/30/2017

The legend is an ordinary text object with the name legend. This text object uses a special syntax to display plot symbols and text. The raw text may look something like:

\l(1) %(1)
\l(2) %(2)

This is what you would see if you were to right-click on the legend object and choose Properties.

For an explanation of syntax and legend customization within the user-interface, see the legend customization discussion in Graph Legends and see the graph legend-related FAQs in the Text Labels & Legends section.

To modify the graph legend using LabTalk:

You can directly change the text in the legend by addressing the text property of the object named legend:

legend.text$ = Test
\l(1) %(1)
\l(2) %(2);

You can use the legendupdate X-Function to change the way the %(#) is interpreted. For example:

legendupdate mode:=lname;  // display long name
legendupdate mode:=7 custom:=@WS;  // display sheet name, customized option


Other Substitution notations can also be used for the legend, the X and Y axis titles, or ant text object. Please refer to Text Label Options for more details.



Keywords:object, control, programming, substitution