フィルターのクリア

how to make a stacked bar graph?

1 回表示 (過去 30 日間)
Minka Califf
Minka Califf 2018 年 6 月 7 日
コメント済み: Minka Califf 2018 年 6 月 8 日
i am trying to make my bar graph stacked. As of now it shows the total population in each state, and I want the stacked part to show the number of homeless individuals (found in column D of the excel file), as well as number of CoCs if possible (column C). How can I add this to my graph? Any help is greatly appreciated.
%plotting
figure
bar(states,totpop)
xlabel('States', 'Fontsize', 18)
ylabel('Numer of Homeless Persons (Millions)', 'Fontsize', 18)
title('HOMELESSNESS IN AMERICA 2017', 'fontsize', 24);
set(gcf,'color','w');
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
grid on
legend({'Total Population','Homeless Population'},'Location','northeast')
Looking for something like this:
  2 件のコメント
dpb
dpb 2018 年 6 月 7 日
Use the optional style argument with value 'stacked'
bar(states,data,'stacked')
where data is the array of columns wanted from the spreadsheet
See
doc bar % for examples and syntax details
Minka Califf
Minka Califf 2018 年 6 月 8 日
Works great - thanks! If you would like to post as an answer I will accept it.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeBar Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by