legend
Update legend text of axes. Turn on/off the legend of axes. Toggle the states if no argument is used.
Syntax
legend()
legend('on')
legend('off')
legend(str1, str2, ...)
legend(str-cell)
legend(h-vector, str-cell)
Inputs
- on/off
- Determines whether legend is set to on or off.
- str1, str2
- Legend text. str1 is the text for the first curve, str2 is the text for the second curve, etc.
- str-cell
- Legend text in a cell array.
- h-vector
- Handles of the curves which show legends.
Example
Simple legend example.
clf;
plot(rand(1, 10));
legend('on');
legend('legend text');
Add legends for selected curves.
clf;
hold on;
h1 = plot(rand(10,1),'--o');
h2 = plot(rand(10,1),'-s');
h3 = plot(rand(10,1),'r^');
legend([h2,h3],{'curve2','curve3'});