%% Add Plot to Existing Graph
% This example shows how to add a plot to an existing graph.
%
% Plot of a sine wave along the domain [0,5].

% Copyright 2015 The MathWorks, Inc.


x1 = linspace(0,5);
y1 = sin(x1);

figure % new figure window
plot(x1,y1)

%% 
% Use |hold on| to retain the line plot and add a new plot to the
% graph. Add a stem plot along the domain [0,8]. Then, use |hold
% off| to reset the hold state so that new plots replace existing plots,
% which is the default behavior.

hold on 

x2 = 0:0.5:8;
y2 = 0.5*sin(x2);
stem(x2,y2)

hold off % reset hold state
%%
% MATLAB(R) rescales the axis limits each time a new plot is added to a
% graph.
