How can one draw a plot of this table?

1 次查看(过去 30 天)
alpedhuez
alpedhuez 2021-7-30
重新打开: Cris LaPierre 2021-7-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?

采纳的回答

Dave B
Dave B 2021-7-30
编辑:Dave B 2021-7-30
If you want a simple line plot, you could do
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)
For a bar chart you might do:
bar(T.date, [T.visitors T.sales])
Lot's more options for different visualizations can be found here
  3 个评论
alpedhuez
alpedhuez 2021-7-30
编辑:alpedhuez 2021-7-30
But can one stackedplot as multiple graphs in one x-y?
Dave B
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 CenterFile Exchange 中查找有关 Line Plots 的更多信息

标签

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by