title: Legend on scatter3 in Matlab
body: <p>I was expecting that to work, but I am missing what is a "vector of handles", from MATLAB helpfile.</p>
  
  <blockquote>
    <p>LEGEND(M), where M is a string matrix or cell array of strings, and</p>
    
    <p>LEGEND(H,M) where H is a vector of handles to lines and patches also
    works.</p>
  </blockquote>
  
  <pre><code>myone = ones(20,1);
  mytwo = ones(20,1)+1;
  rows = vertcat(myone,mytwo);
  mylabels = {'Alpha', 'Beta'};
  
  figure
  grouplabels = mylabels(rows);
  h = scatter3(rand(40,1),rand(40,1),rand(40,1),20,rows,'filled'), ...
      view(-33,22)
  legend(handle(h),grouplabels)
  
  xlabel('X')
  ylabel('Y')
  zlabel('Z')
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/NbrDo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NbrDo.png" alt="enter image description here"></a></p>