function draw_landmarks(l, color, color2)

if size(l,1) == 6
   plot(l([3 5],:),l([4 6],:),'color',color);
%   held = ishold; hold on;
%   plot( l(3,:),l(4,:),'x','color',color );
%   if ~held, hold off; end
   
elseif size(l,1) == 4
   plot(l([1 3],:),l([2 4],:),'color',color);
elseif size(l,1) == 5
   %plot in rho,phi space
   num_p = 20;
   t = [linspace(0,2*pi,num_p-1)'; nan]*ones(1,size(l,2));
   xt = 3*cos(t);
   yt = 3*sin(t);
   
   vrep = ones(num_p,1);
   rho = vrep*l(1,:);
   phi = vrep*l(2,:);
   crr = l(3,:);
   crp = l(4,:);
   cpp = l(5,:);
   
   %cholesky factorization
   a = vrep*sqrt(crr);
   b = vrep*crp./a;
   c = vrep*sqrt(cpp - crp.^2./crr);
   
   %ellipses
   X = a.*xt + b.*yt + rho;
   Y = c.*yt + phi;
   
   if nargin==2, color2 = color; end
   if nargin==1, color='b'; color2='r'; end

   plot(phi(1,:),rho(1,:), 'x', 'color', color);
   held = ishold; hold on;
   plot(Y(:),X(:),'color',color2);
   if 1
      labels = num2str((1:size(l,2))');
      text(phi(1,:),rho(1,:),labels, 'color', color);
   end

   if ~held, hold off; end
   
elseif size(l,1) == 9
   %also plot error bounds
   rho = l(1,:);
   phi = l(2,:);
   N = 5;
   x = linspaceV(l(3,:)',l(5,:)',N)';
   y = linspaceV(l(4,:)',l(6,:)',N)';
   num_p = size(x,1);
   
   vrep = ones(num_p,1);
   cphi = vrep*cos(phi);
   sphi = vrep*sin(phi);
   
   crr = vrep*l(7,:);
   crp = vrep*l(8,:);
   cpp = vrep*l(9,:);
   
   d = (cphi.*y - sphi.*x);
   
   del = 3*sqrt(d.^2.*cpp - 2*d.*crp + crr);
   
   dx = del.*cphi;
   dy = del.*sphi; 
   
   num_l = size(x,2);
   x = [x; nan*ones(1,num_l)];
   y = [y; nan*ones(1,num_l)];
   dx = [dx; nan*ones(1,num_l)];
   dy = [dy; nan*ones(1,num_l)];
   
   
   if nargin==2, color2 = color; end
   if nargin==1, color='b'; color2='r'; end
   
   held = ishold;
   plot( x(:),y(:),'color',color);
   hold on;
   plot([x(:)+dx(:);x(:)-dx(:)],[y(:)+dy(:);y(:)-dy(:)],'color',color2);
   plot( x(1,:),y(1,:), 'x', 'color', color)
   
   if 1
      labels = num2str((1:size(x,2))');
      text(x(3,:),y(3,:),labels, 'color', color);
   end
   if(~held), hold off; end
  
end


