legend
Add a legend to the chart.
Syntax
Section titled “Syntax”legend(label1, label2, ...)legend({'label1', 'label2'})legend('off')legend('Location', 'best')Description
Section titled “Description”Adds a legend identifying each plotted series by color/style and label. Labels can be passed individually or as a cell array. Trailing name-value pairs control position and appearance — 'Location' accepts 'north', 'south', 'east', 'west', 'best', 'northeastoutside', etc.
Examples
Section titled “Examples”plot(x, y1, x, y2);legend('Series A', 'Series B', 'Location', 'northeast')