title: Set axis limits when plotting 2 vertical axes in MATLAB via plotyy
body: <p>I have the following data sets to plot:</p>
  
  <pre><code>data1 = [ 3 6 99 4 5];
  data2 = [ 0.2 1.5 1.75 1.0 1.2];
  </code></pre>
  
  <p>What's peculiar about my situation is that I need data point <code>data1(3)</code>, which is equal to <code>99</code>, <em>not</em> show up on the graph. I'm using 99 as a way of pushing observations outside the desired axis limits so that there are no visible observations for certain values of the independent variable.  (I'm plotting the data points with markers only, no lines.)</p>
  
  <p>While <code>data1</code> and <code>data2</code> have totally unrelated scales and meanings, they share the exact same dependent variable:</p>
  
  <pre><code>X=40:1:44
  </code></pre>
  
  <p>I'm plotting with the following commands, which I derived from the <a href="http://www.mathworks.com/help/matlab/ref/plotyy.html" rel="nofollow">MATLAB plotyy documentation page</a>:</p>
  
  <pre><code>[AX,H1,H2] = plotyy(X,data1,X,data2);
  
  set(get(AX(1),'Ylabel'),'String','This is vertical axis 1') 
  set(get(AX(2),'Ylabel'),'String','This is vertical axis 2')     
  
  set(H1,'LineStyle','none','Marker','*');
  set(H2,'LineStyle','none','Marker','s');
  </code></pre>
  
  <p>So far, so good.  What I cannot figure out is how to enforce the correct limits on both of the vertical axes.  My desired limits are:</p>
  
  <pre><code>ylimits1=[0 3]
  ylimits2=[0 10]
  </code></pre>
  
  <p><strong>How can I set limits for each vertical axis?</strong></p>
  
  <hr>
  
  <p>I have tried this</p>
  
  <pre><code>set(get(AX(1),'Ylim'),ylimits1) 
  set(get(AX(2),'Ylim'),ylimits2) 
  </code></pre>
  
  <p>and </p>
  
  <pre><code>foo = gca
  set(foo(1),'ylim',ylimits1);
  set(foo(2),'ylim',ylimits2);
  </code></pre>
  
  <p>but neither work.</p>