How to make stack plot with y axis consisting of multiple plots?
古いコメントを表示
I make the plots by the following code using subplots
subplot(2,1,1)
for i=2:size(data,1)
plot_fig(i) = plot(data(1,:),data(i,:),'LineWidth',2.5);
hold on
end
subplot(2,1,2)
plot_fig = plot(data(1,:),y_2(2,:),'LineWidth',2.5);

But I was wondering if can do the same but using stackedplot() considering that my top plot will have multiple plots in it.
The x-axis is same for the above 2 plots. That means these plots can be a stacked plot.
9 件のコメント
VBBV
2020 年 11 月 18 日
can you attach your data file?
Jay Vaidya
2020 年 11 月 18 日
編集済み: Jay Vaidya
2020 年 11 月 18 日
writematrix([data;y_2]','stacked.xlsx'); % write to excel file
tbl = readtable('stacked.xlsx'); % convert to table array
stackedplot(tbl); % plot using stackedplot function
Since there are no variables in your attached data files, the o/p plot shows Var1 Var2... VarN
See the fig attached
Adam Danz
2020 年 11 月 18 日
We can't run your code because variable st and en are missing.
stackedplot(y_2,data')
gives me this plot,

Jay Vaidya
2020 年 11 月 19 日
Jay Vaidya
2020 年 11 月 19 日
編集済み: Jay Vaidya
2020 年 11 月 19 日
Peter Perkins
2020 年 11 月 19 日
"stacked but not using subplot" makes no sense. The ONLY way you can have two plots in one figure is subplots. It sounds like you are looking for the VARS input argument to stackedplot, which will let you group Var1 through Var5 in one subplot and Var6 in another?
Jay Vaidya
2020 年 11 月 19 日
Adam Danz
2020 年 11 月 19 日
Also, I just uploaded a function to the file exchange, stackedaxes() which mimicks Matlab's stackedplot but returns the axis handles and allows you to access or add to the content of the figure.

採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Annotations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


