Multiple Lines in a Stacked Plot

22 ビュー (過去 30 日間)
Felipe Dicker
Felipe Dicker 2023 年 11 月 21 日
コメント済み: Dyuman Joshi 2023 年 11 月 21 日
I'd like to have 3 different vectors plotted onto 2 graphs within a stacked plot. For example, I wish to plot vectors a and b in the first graph of the stacked plot and variable c on the second graph, with the x-axis of the stacked plot being another vector, t. How would I be able to do that?

採用された回答

Dyuman Joshi
Dyuman Joshi 2023 年 11 月 21 日
移動済み: Dyuman Joshi 2023 年 11 月 21 日
If you are working with R2018b or a later version, check out stackedplot
%Random data
n = 10;
t = (1:n).';
a = zeros(n,1);
b = ones(n,1);
c = rand(n,1);
data = table(t, a, b, c)
data = 10×4 table
t a b c __ _ _ ________ 1 0 1 0.89507 2 0 1 0.099055 3 0 1 0.70476 4 0 1 0.65991 5 0 1 0.78316 6 0 1 0.80992 7 0 1 0.32504 8 0 1 0.10411 9 0 1 0.6188 10 0 1 0.34006
vars = {["a" "b"], "c"};
stackedplot(data, vars, "XVariable", "t")
  4 件のコメント
Felipe Dicker
Felipe Dicker 2023 年 11 月 21 日
Works great, thank you so much!
Dyuman Joshi
Dyuman Joshi 2023 年 11 月 21 日
You are welcome!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by