bar chart - Bar plot with labels in Matlab -


how can add vertical labels of current value bar plot in matlab?

i want add current value "here" is:

enter image description here

the question linked in comments 1 way it. there other ways customize bar plots, instance see this article (although starting hg2, internals have changed considerably, got trickier reach inside , retrieve data need).

if you're willing dig deep, here solution should work matlab r2014b , newer (note i'm using undocumented properties hidden "face" graphic objects created bar plot):

y = rand(3,4); h = bar(y); drawnow   % needed reason!  opts = {'verticalalign','middle', 'horizontalalign','left', ...     'fontsize',8, 'rotation',90}; i=1:numel(h)     clr = h(i).face.colordata(1:3);     vd = h(i).face.vertexdata;     xy = double(vd(1:2,2:4:end) + vd(1:2,4:4:end)) / 2;     j=1:size(xy,2)         text(xy(1,j), xy(2,j), sprintf(' %.2g',xy(2,j)), ...             'color','k', opts{:})     end end 

barplot


Comments