title: Matlab legend colors don't match lines
body: <p>Not sure what is going wrong here. I created a minimal example below:</p>
  
  <pre><code>clear
  steps = 1:6;
  labels = cell(length(steps),1);
  xvals = 1:10;
  fig = figure(1);
  ax = axes('parent',fig);
  hold on
  for ii=1:length(steps)
      s=steps(ii);
      yvals = zeros(length(xvals)) + ii;
      labels{ii} = ['gain = ' num2str(s)];
      plot(ax,xvals,yvals);
  end
  legend(ax, labels);
  hold off
  </code></pre>
  
  <p>And the result on my system is:</p>
  
  <p><a href="https://i.stack.imgur.com/UjeO3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UjeO3.png" alt="Wrong plot colors"></a></p>
  
  <p>With less lines it can even put colors in the legend that aren't even on the plot. What is happening?!</p>