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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Bar Plots 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by