Label a stem plot with the height of each lollipop

labelstem(k,Y,fignum);

function success = labelstem(k,Y,fignum);
%LABELSTEM labels a plot created by STEM with the values on the plot.
% Note that best results are when the y values are close to each other,
% and there are only about 10 elements or less.
%
% LABELSTEM(k,Y,figure) where k is the discrete time index, Y are the
% values of the series, and figure is the figure handle of the STEM plot.
%
% Authored by Nathan West September 2009
%
figure(fignum);
for element = 1:numel(Y)
val = sprintf('%3.2f',Y(element));
if sign(Y(element)) == 1
text(k(element)-.3,Y(element)+.08*max(Y),val);
else
text(k(element)-.3,Y(element)-0.08*max(Y),val);
end
end