MATLAB: Plotting more than one graph

figuregraphMATLAB

I am attempting to produce 2 graphs (see below) however after running the code only one graph (Stock Price) is being displayed. How can I get them both to show?
% LogPriceReturn Graph
x = Timestep; % sets x axis equal to the 'Timestep'
y = LogPriceReturn; % sets y axis equal to the 'LogPriceReturn'
plot(x,y, 'Marker','o', 'MarkerFaceColor','black'); hold on % plots graph of x and y, using 'hold on' command to retain each loop result
title('Log Price Return'); % sets the title of graph
xlabel('Timestep'); % sets x-axis label of graph
ylabel('Log Price Return Graph'); % sets y-axis label of graph
axis([1 n -1.5 1.5]); % formats axis limits
%StockPrice Graph
x = Timestep;
y = StockPrice;
plot(x,y, 'Marker','o', 'MarkerFaceColor', 'black'); hold on
title('Stock Price');
xlabel('Timestep');
ylabel('Stock Price');
axis([1 n -1.5 1]);

Best Answer

Before you start the second plot use
hold on
Related Question