How can one draw a plot of this table?
2 ビュー (過去 30 日間)
古いコメントを表示
Suppose I have table T
date visiors sales
1/1/2021 3 100
1/2/2021 5 120
I want to draw a plot of "visitors" and "sales" with date on the x axis. How can one do this?
0 件のコメント
採用された回答
Dave B
2021 年 7 月 30 日
編集済み: Dave B
2021 年 7 月 30 日
plot(T.date, T.visitors)
hold on
plot(T.date, T.sales)
or
plot(T.date, [T.visitors T.sales])
or even:
plot(T.date, T.visitors, T.date, T.sales)
bar(T.date, [T.visitors T.sales])
Lot's more options for different visualizations can be found here
3 件のコメント
Dave B
2021 年 7 月 30 日
You can do this with:
stackedplot(T, {{'visitors' 'sales'}}, 'XVariable', 'Date')
The {{ might be confusing: you can think of this as: each element of the outer cell is an axes, each element of the inner cell is a line in that axes.
This definitely makes more sense when you have multiple plots to 'stack'.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Line Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!