How can one draw a plot of this table?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
alpedhuez
el 30 de Jul. de 2021
Abierta de nuevo: Cris LaPierre
el 30 de Jul. de 2021
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 comentarios
Respuesta aceptada
Dave B
el 30 de Jul. de 2021
Editada: Dave B
el 30 de Jul. de 2021
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 comentarios
Dave B
el 30 de Jul. de 2021
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'.
Más respuestas (0)
Ver también
Categorías
Más información sobre Line Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!