Table Of Contents

legend

Version:
    Last Modified: March 15, 2017

    Adds a legend to 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.

    spd-note-note
    Note  

    You can only use the legend function in the MathScript Console.

    Syntax

    legend ('show')
    legend('off')
    legend(text1, text2, '...')
    legend(text1, text2, '...', pos)

    Inputs

    show

    Shows the legend in the current plot.

    off

    Hides the legend in the current plot.

    text1

    Label in the legend for the first variable.

    text2

    Label in the legend for the second variable.

    ...

    Further text.

    pos

    Position to add the legend to the plot. pos is a string with the following values:

    Name Description
    'north'

    Legend at the top center of the plot.

    'south'

    Legend at the bottom center of the plot.

    'east'

    Legend at the right center of the plot.

    'west'

    Legend at the left center of the plot.

    'northeast'

    Legend in the upper-right corner of the plot.

    'northwest'

    Legend in the upper-left corner of the plot.

    'southeast'

    Legend in the bottom-right corner of the plot.

    'southwest'

    Legend in the bottom-left corner of the plot.

    'northoutside'

    Legend at the top center out of the plot.

    'southoutside'

    Legend at the bottom center out of the plot.

    'eastoutside'

    Legend at the right center out of the plot.

    'westoutside'

    Legend at the left center out of the plot.

    'northeastoutside'

    Legend in the upper-right corner out of the plot.

    'northwestoutside'

    Legend in the upper-left corner out of the plot.

    'southeastoutside'

    Legend in the bottom-right corner out of the plot.

    'southwestoutside'

    Legend in the bottom-left corner out of the plot.

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

    Where This Node Can Run:

    Desktop OS: Windows

    FPGA: This product does not support FPGA devices


    Recently Viewed Topics