histogram style graph with several different data types with each type coloured differently

3 ビュー (過去 30 日間)
I have a bunch of papers using different calculaton methords. I want to graph along the x axis the year the paper was published and on the y have boxes sized corrasponding to the number of papers of a given type published in that year where each type is coloured seperatly like a stacked bar chart. I have tried all manour of things and the closest thing I have got is this using a stacked bar chart but this is basically roated 90degrees from what I want (year on the x and number on the y with coloured boxes indicating type:

採用された回答

dpb
dpb 2021 年 4 月 10 日
Actually, it's not too bad to just make up something...not sure where and why you ran into difficulties without seeing what sort of things you did try, but--
METHODS=categorical(string(('A':'E').')); % easier than typing in your categories
YEARS=[2001:2010].'; % arbitrary years
n=randi(300,numel(YEARS),numel(METHODS)); % generate some numbers by year and method
hB=bar(YEARS,n.','stacked'); % put on stacked bar by year
xlim(xlim+[1 -1]*0.6) % I think extra white space at ends is ugly...
legend(METHODS) % add legend and labels
xlabel('Publication Year'),ylabel('Number Publications by Method')
resulted in
  1 件のコメント
Oliver Nicholls
Oliver Nicholls 2021 年 4 月 11 日
Thankyou very much I was confused on the data type for n. Much appreaciated!

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

その他の回答 (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