Hi Ibro,
You can calculate the bar offsets within each group and use the text function to plot the y values on top of each bar.
y = [2 3 4 ; 1 5 2; 6 2 5];
b = bar(y);
width = b.BarWidth;
for i=1:length(y(:, 1))
row = y(i, :);
offset = ((width + 0.5) / length(row)) / 2;
x = linspace(i-offset, i+offset, length(row));
text(x,row,num2str(row'),'vert','bottom','horiz','center');
end
1 件のコメント
このコメントへの直接リンク
https://jp.mathworks.com/matlabcentral/answers/351883-value-on-top-of-grouped-bar-graph#comment_475199
このコメントへの直接リンク
https://jp.mathworks.com/matlabcentral/answers/351883-value-on-top-of-grouped-bar-graph#comment_475199
サインインしてコメントする。