【发布时间】:2018-12-30 14:11:52
【问题描述】:
我被 Matlab 中的条形图困住了。我让它在 Matlab 帮助和这个论坛上工作,直到这里,但在 x 轴上,仍然只有 2 个名称。我想在栏下有“名称”和现在显示 2 个名称的“类别”。谢谢!
values = [4 10...
11 2 3;...
4 1...
5 2 -10];
names = {'PreSplitTotalEON' 'PostSplitTotalEON'...
'PreSplitPureEON' 'PostSplitPureEON' 'PostSplitUniper';...
'PreSplitTotalRWE' 'PostSplitTotalRWE'...
'PreSplitPureRWE' 'PostSplitPureRWE' 'PostSplitInnogy'};
categories = {'EON', 'RWE'};
b = bar(values,'FaceColor','flat');
xticklabels([names(1,:)';names(2,:)'])
% This will set labels to be used for each tick of the x-axis
xticks(1:1:length([names(1,:)';names(2,:)']))
% This will set how many ticks you want on the x-axis. Here, there
% should be 48 ticks being generated. One for each piece of data you have.
xtickangle(90)
% This will rotate the label so that the labels will not overlap
% with one another. This is in degrees.
for k = 1:size(values,2) % for fancier colors.
b(k).CData = k;
end
【问题讨论】:
标签: matlab plot matlab-figure