stacked plot of subplots that includes three graphs

2 次查看(过去 30 天)
Hello,
I am trying to make a stacked plot of three subplots. For each subplot, I need to keep plots of three data vs time data.
A=load('Volume_15_400_M_R.txt');
B=load ('time_400.txt'); % time plot that needs to be in common x-axis
C=load('Volume_15_400_M_W_F.txt');
D=load('Volume_control.txt');
E=load('Volume_10_400_M_R.txt');
F=load('Volume_10_400_M_W_F.txt');
G=load('Volume_5_400_M_R.txt');
H=load('Volume_5_400_M_W_F.txt');
For subplot (3,1,1)
I am trying to keep A vs B, C vs B, and D vs B plots
For subplot (3,1,2)
I am trying to keep E vs B, F vs B, and D vs B plots
For subplot (3,1,3)
I am trying to keep G vs B, H vs B, and D vs B plots
Finally, I need to make stacked plot of above subplots.
Your suggestions will be highly appreciated.
Thanks
Dharma
  2 个评论
Dharma Khatiwada
Dharma Khatiwada 2022-10-21
Thank you for the response. I am not exactly sure. But, trying to keep three plots in each subplot and stacking the subplots.
something like given figure. I am trying to keep just a single x axis value.

请先登录,再进行评论。

回答(1 个)

Walter Roberson
Walter Roberson 2022-10-21
subplot(3,1,1)
plot(B, [A(:), C(:), D(:)]);
subplot(3,1,2)
plot(B, [E(:), F(:), D(:)]);
subplot(3,1,3)
plot(B, [G(:), H(:), D(:)]);
  3 个评论
Walter Roberson
Walter Roberson 2022-10-21
subplot(3,1,1)
plot(B, [A(:), C(:), D(:)]);
xticks([])
subplot(3,1,2)
plot(B, [E(:), F(:), D(:)]);
xticks([])
subplot(3,1,3)
plot(B, [G(:), H(:), D(:)]);
This will probably still not look exactly the way you would prefer.
The plot you posted as an exaple is produced by the stackedplot command. Unfortunately, that only permits a single line for each section. There are ways to get it to draw what look like multiple lines, but there is no supported method to get those lines in different colors.
If is possible to call stackedplot() and struct() the result (ignoring the warning), and then access the Axes property of that to get an N x 1 array of axes handles. You can then use those handles to draw additional lines. This is possible -- but it is not supported.
Dharma Khatiwada
Dharma Khatiwada 2022-10-21
Thank you very much, Walter!
I truly appreciate your help. Yes, I am not getting what I was originally thinking but your ideas already helping me to bring my work in a good shape.

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by