for i=1:20 A{i}=randi([100,1000]); B{i}=randi([100,300]); C{i}=randi([2,30]); D{i}=randi([2,30]); E{i}=randi([0,2]);endhold on;index=10;numNearbyCHs=20;set(gcf, 'Units', 'Normalized', 'OuterPosition', [0, 0.04, 1, 0.96]);for i=1:numNearbyCHs y=[A{i}/5,B{i}/5,C{i}*5,D{i}*5]; bh = bar(i,y,'stacked','FaceColor', 'Flat'); % Choose a color map (using "lines" in this example)
if i~=index colors = mat2cell(lines(numel(bh)),ones(numel(bh),1), 3); set(bh, {'CData'}, colors) else colors = mat2cell(jet(numel(bh)),ones(numel(bh),1), 3); set(bh, {'CData'}, colors) end arrayfun(@(i) text(bh(i).XEndPoints,bh(i).YEndPoints,num2str(bh(i).YEndPoints.','%0.1f'), ... 'verticalalignment','top','horizontalalign','center','Color','white'),[1:numel(bh)]) end
I would like to display value of E{i} on top of each stacked bar and each value of i on X-axis. Can somebody help me on this. I am really stuck on this. I would really appriate your help.
Best Answer