MATLAB: Text label above the bars

histogramslabels

Hi there,
I am new in matlab and I am trying to put text labels above the bars, so that A is above first one, B above second one etc…Can you help me with this
thank you
R
y = [10,20,30,15];
a = bar(y);
labels = {'A', 'B', 'C', 'D'};

Best Answer

This works:
y = [10,20,30,15];
a = bar(y);
labels = {'A', 'B', 'C', 'D'};
xt = get(gca, 'XTick');
text(xt, y, labels, 'HorizontalAlignment','center', 'VerticalAlignment','bottom')