function label(varargin)
% label(P,'text')
% label(P1,'text1',P2,'text2',...,Pn,'textn')
%
% plot 'text' at point P in graph, P is vector of length 2 or 3
% can also be used for multiple points P1,...,Pn
%
% Examples:
%  P=[1;2]; Q=[3;4]; plotpoints([P,Q],'o:'); label(P,'P',Q,'Q')
%  P=[1;2;3]; Q=[2;1;3]; plotpoints([P,Q],'o:'); label(P,'P',Q,'Q'); nice3d

n = nargin;
if mod(n,2)~=0
  error('need even number of arguments')
else
  for k=1:n/2
    P = double(varargin{2*k-1});
    str = varargin{2*k};
    if length(P)==2
      text(P(1),P(2),str,'FontSize',15,'VerticalAlignment','bottom')
    elseif length(P)==3
      text(P(1),P(2),P(3),str,'FontSize',15,'VerticalAlignment','bottom')
    else
      error('P must be vector of length 2 or 3')
    end
  end
end
