%% Add Horizontal Legend Above Graph
% Create a graph of sine and cosine. Add a horizontal legend above the
% axes.

% Copyright 2015 The MathWorks, Inc.


x = -pi:pi/20:pi;
y1 = sin(x);
y2 = cos(x);

figure
plot(x,y1,'-ro',x,y2,'-.b')
legend('sin(x)','cos(x)','Location','northoutside','Orientation','horizontal')