Plot multiple variables with stackedplot with data for the x-axis?
古いコメントを表示
Hi,
I am using the stackedplot function to plot multiple variables onto the same y-axis.
The code looks like this:
figure
stp = stackedplot(table,vars);
The variable table is a table where each column is one of the variables I want to plot. Vars is a cell array containing the table column names. So this code works for me, but I want the x-axis to be a time axis (I have a vector with the time values). Right now the x-axis is the number of the row in table.
How can I change the x-axis to have my time values?
Thanks
Selim
採用された回答
その他の回答 (1 件)
dpb
2022 年 8 月 12 日
From the doc, about the third input syntax description is
stackedplot(___,'XVariable',xvar)
3 件のコメント
Selim Öngüdü
2022 年 8 月 12 日
Well, yes, you must specify only one variable for the x axis, stackedplot doesn't handle different x,y combinations for various plots; only one x for all y.
Adam Danz
2022 年 8 月 15 日
The syntax dpd recommended is for table syntax only.
'xvar' could be a string or index indicating a column in a table.
stackedplot is designed to compare multiple Ys against 1 X. If you want to use multiple X's then I recommend using nx1 tiledlayout with TileSpacing = none.
カテゴリ
ヘルプ センター および File Exchange で Tables についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!