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 个评论
回答(1 个)
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
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Subplots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!