Plotting more than one graph

1 次查看(过去 30 天)
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]);

采纳的回答

Walter Roberson
Walter Roberson 2017-1-28
Before you start the second plot use
hold on
  4 个评论
David Ramirez
David Ramirez 2020-7-1
I think he means he wants to seperate graphs and only one populates. I am having the same problem
Walter Roberson
Walter Roberson 2020-7-1
I suggest that for debugging purposes that you use four subplots, the first as normal, the second one showing the first plot, the third one showing the second plot, and the fourth showing the interpolated difference between the two (or just subtract the two if they have the same time scale.) This will give you information to determine whether the plots are in fact similar enough that they are overlaying each other, and will also give you information about whether one of the plots is being badly cut off due to the xlim / ylim

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

标签

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by