StackedPlot with two tables with specific variables
8 次查看(过去 30 天)
显示 更早的评论
I have two tables say table A and table B. A and B has different number of variables but the same number of rows.
following the syntax of stackedplot if I want to do a stackedplot for A
I would write something like this stackedplot(A,[''variable name 1''," [variable name 2']")
My question:
I want to have stacked plot of two tables A and B but specific variables from table A and specific variables from table B
stackedplot(A,["variable1ofA","var2ofA", "var3ofA"],B,["var1ofB","var2ofB"])
The syntax for multiple table is stackedplot(tbl1,tabl2) how do I specify which variables of each table ?
How can I achieve this ?
Thank you
0 个评论
采纳的回答
Cris LaPierre
2024-2-9
If they have the same number of rows, I think what you would want to do is
T = [A(:,["variable1ofA","var2ofA", "var3ofA"]),B(:,["var1ofB","var2ofB"])]
stackedplot(T)
If the tables do not share the same variable names, this may work as well (untested)
stackedplot([A,B],["variable1ofA","var2ofA", "var3ofA","var1ofB","var2ofB"])
6 个评论
Cris LaPierre
2024-2-9
The 2nd syntax should work. I did have to make sure there are no shared variable names between the 2 tables, and that both tables have the same number of rows. Here's a working example.
x = (0:0.1:25).';
TA = array2table([x sin((1:4).*2.*pi.*x/25)]);
TB = array2table([x sin((5:8).*2.*pi.*x/25)]);
TB.Properties.VariableNames = ["X","Y1","Y2","Y3","Y4"];
stackedplot([TA,TB],["Var2","Var3", "Var4","Y1","Y2"])
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!