title: Legend in a bar plot in Matlab
body: <p>How can I plot a legend in a bar plot in Matlab? Here is the code:</p>
  
  <pre><code>Y = [1.5056
  0.72983
  3.4530
  3.2900
  1.4839
  12.9 ];
  n = length(Y);
  h = bar(Y);
  colormap(summer(n));
  grid on
  
  l = cell(1,6);
  l{1}='L'; l{2}='B'; l{3}='R'; l{4}='P'; l{5}='h'; l{6}='Ri';    
  legend(h,l);
  </code></pre>
  
  <p>This give an error: <em>Warning: Ignoring extra legend entries.</em> I tried solutions which I found on the <a href="http://stackoverflow.com">SO</a> and web, but I couldn't resolve this.</p>