title: MATLAB graph plotting: assigning legend labels during plot
body: <p>I am plotting data in a typical MATLAB scatterplot format. Ordinarily when plotting multiple datasets, I would use the command 'hold on;', and then plot each of the data, followed by this to get my legend:</p>
  
  <pre><code>legend('DataSet1', 'DataSet2') % etcetera
  </code></pre>
  
  <p>However, the (multiple) datasets I am plotting on the same axes are not necessarily the same datasets each time. I am plotting up to six different sets of data on the same axes, and there could be any combination of these shown (depending on what the user chooses to display). Obviously that would be a lot of elseif's if I wanted to setup the legend the traditional way.</p>
  
  <p>What I really would like to do is assign each DataSet a name <em>as it is plotted</em> so that afterwards I can just call up a legend of all the data being shown.</p>
  
  <p>...Or, any other solution to this problem that anyone can think of..?</p>