Company Events Academic Community Support Solutions Products & Services Contact NI MyNI

legend (MathScript RT Module Function)

LabVIEW 2012 MathScript RT Module Help

Edition Date: June 2012

Part Number: 373123C-01

»View Product Info
Download Help (Windows Only)

Owning Class: plots

Requires: MathScript RT Module

Syntax

legend off

legend(text1, text2, ...)

legend(text1, text2, ..., location)

legend(text1, text2, ..., 'location', opt)

legend(text1, text2, ..., 'location', pos)

legend obj off

legend(obj, ...)

Description

Adds a legend to the current plot or the plot specified by the plot object. legend off hides the legend in the current plot. You can specify as many labels in the legend as there are variables. The legend function works exclusively with the plot function.

Examples

Inputs

Name Description
text1 Specifies the label in the legend for the first variable.
text2 Specifies the label in the legend for the second variable.
location Specifies where to add the legend to the plot. location is a scalar that accepts the following values.

1 (default) Adds a legend to the upper-right corner of the plot.
2 Adds a legend to the upper-left corner of the plot.
3 Adds a legend to the bottom-left corner of the plot.
4 Adds a legend to the bottom-right corner of the plot.
opt Specifies where to add the legend to the plot. opt is a string that accepts the following values:

'north', 'N' Adds a legend to the top center of the plot.
'south', 'S' Adds a legend to the bottom center of the plot.
'east', 'E' Adds a legend to the right center of the plot.
'west', 'W' Adds a legend to the left center of the plot.
'northeast', 'NE' Adds a legend to the upper-right corner of the plot.
'northwest', 'NW' Adds a legend to the upper-left corner of the plot.
'southeast', 'SE' Adds a legend to the bottom-right corner of the plot.
'southwest', 'SW' Adds a legend to the bottom-left corner of the plot.
'northoutside', 'NO' Adds a legend to the top center out of the plot.
'southoutside', 'SO' Adds a legend to the bottom center out of the plot.
'eastoutside', 'EO' Adds a legend to the right center out of the plot.
'westoutside', 'WO' Adds a legend to the left center out of the plot.
'northeastoutside', 'NEO' Adds a legend to the upper-right corner out of the plot.
'northwestoutside', 'NWO' Adds a legend to the upper-left corner out of the plot.
'southeastoutside', 'SEO' Adds a legend to the bottom-right corner out of the plot.
'southwestoutside', 'SWO' Adds a legend to the bottom-left corner out of the plot.
'best', 'B' Adds a legend to the best position of the plot that fits the legend.
'bestoutside', 'BO' Adds a legend to the best position out of the plot that fits the legend.
pos Specifies the position to add the legend to the plot. pos must be an array of four values. The first and second values specify the horizontal and vertical distance from the bottom-left corner of the legend to the bottom-left corner of the plot area. The third and fourth values specify the width and height of the legend. LabVIEW automatically adjusts the width and height to fit labels in the legend. The values in pos are normalized such that the bottom-left corner and the upper-right corner of the plot area are (0, 0) and (1, 1), respectively.
obj Specifies the reference to the plot object. legend accepts axes object, line object, or legend object.

Details

The following table lists the support characteristics of this function.

Supported in the LabVIEW Run-Time Engine No (always ignored)
Supported on RT targets No

Examples

X = 0:0.1:1;
Y = X.*X;
Z = sin(X);
plot(X, Y, 'r', X, Z, 'b')
legend('quadratic', 'sin')

X = 0:0.3:6;
Y = cos(X);
Z = sin(X);
plot(X, Y, 'bo-', X, Z, 'mo-')
legend('cos', 'sin', 3)

X = 0:0.3:6;
Y = cos(X);
Z = sin(X);
plot(X, Y, 'bo-', X, Z, 'mo-')
legend('cos', 'sin', 'location', 'EO')

X = 0:0.3:6;
Y = cos(X);
Z = sin(X);
plot(X, Y, 'bo-', X, Z, 'mo-')
legend('cos', 'sin', 'location', [0.2, 0.3, 0.1, 0.1])

Related Topics

plot


 

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
Add Comments 1 2 3 4 5 submit