title: Save bar plot in subplot
body: <p>I want to save my plotted figure in MATLAB to a <code>fig</code> file. Currently I'm using the following code:</p>
  
  <pre><code>hf1 = figure();
  p1=uipanel('Parent',hf1);
  a1=subplot(2,1,1,'Parent',p1);
  %b1=plot(a1,1:9);
  b1=bar(a1,1:9);
  a2=subplot(2,1,2,'Parent',p1);
  b2=bar(a2,1:9);
  %b2=plot(a2,1:9);
  hf2 = figure('Visible', 'on');   
  hAxes = copyobj(findobj(p1,'Type','Axes'), hf2);
  saveas(hf2,'case2.fig','fig');
  </code></pre>
  
  <p>But then I get the following error:</p>
  
  <blockquote>
    <p>??? Error using ==> getProxyValueFromHandle at 15
    Input must be a valid handle.</p>
    
    <p>Error in ==> plotedit at 91
                   [varargout{1:nargout}] = feval(args{:});</p>
    
    <p>Error in ==> specgraph.barseries.preserialize at 10
    peerVals = plotedit({'getProxyValueFromHandle',hPeers});</p>
    
    <p>Error in ==> hgsaveStructDbl at 81
           olddata{i} = {hh,preserialize(hh)};</p>
    
    <p>Error in ==> hgsave at 63
       hgS = hgsaveStructDbl(h, SaveAll);</p>
    
    <p>Error in ==> saveasfig at 7
    hgsave( h, name );</p>
    
    <p>Error in ==> saveas at 126
       feval( ['saveas' format], h, name )</p>
    
    <p>Error in ==> testbar at 11
    saveas(hf2,'case2.fig','fig');</p>
  </blockquote>
  
  <p>But when I replace the <code>bar</code> with <code>plot</code> in the code (I commented them out now^^), then I can save the figure successfully.</p>
  
  <p>The version I'm using is MATLAB R2010a.</p>