MATLAB Answers

Bar plot using multiple table variables?

177 views (last 30 days)
Jeffrey Marak
Jeffrey Marak on 28 May 2019
Answered: Prasanth Sikakollu on 18 Jun 2019
I have a table as attached image. how do I plot First column on X and Varname2, Varname3 and Varname4 on Y axis together on the same plot?? I tried hold on function but the previous plots just get replaced.

Answers (2)

Peter Perkins
Peter Perkins on 12 Jun 2019
It's not completely clear what you are asking for, but my guess is that you want bar, with the 'stacked' input, and t{2:7,2:4} as your (one) input. Then label the bars with t.LandUse. And maybe use t{1,2:4} in some kind of legend?

  1 Comment

Jeffrey Marak
Jeffrey Marak on 18 Jun 2019
I want to plot like the image attached

Sign in to comment.

Prasanth Sikakollu
Prasanth Sikakollu on 18 Jun 2019
You can try the following code. Assuming that the data is present in the table named "table_data".
% table_data has the data in the form of a table.
bar(categorical(table_data{1:7, 1}), table_data{1:7, 2:4});
xlabel('LandUse Types');
Its outcome is the following bar graph.
For more information on Bar charts, refer to the following documentation link.
Hope it helps


Sign in to comment.


Translated by