www.gusucode.com > graphics 案例源码程序 matlab代码 > graphics/ModifyLegendAppearanceExample.m

    %% Modify Legend Appearance
% Plot a line chart and a stem chart. Add a legend to the axes and set
% properties of the legend using name-value pair arguments. When you
% specify name-value pair arguments, you must specify the labels using a
% cell array.

x = linspace(-3,3,25);
y1 = sin(x);
plot(x,y1)

hold on
y2 = cos(x);
stem(x,y2)
hold off

legend({'sin(x)','cos(x)'},'FontSize',12,'TextColor','blue')