title: matplotlib discrepancy with iPython notebook and python file
body: <p>I have a strange problem with matplotlib that I can not seem to figure out. When using the ipython notebook with the pylab flag, <code>ipython notebook --pylab inline</code> I have a line of code that looks like this that is used to generate a colorbar with matplotlib:</p>
  
  <pre><code>im = ax.imshow(df, vmin=vmin, vmax=vmax)
  </code></pre>
  
  <p>The code works correctly and I get a nice colorbar. When I run this code as a python file I get an error, <code>NameError: name 'ax' is not defined</code>. I understand that the <code>ipython notebook --pylab inline</code> automatically imports a bunch of stuff into the notebook, but I cannot figure out what I need to import to fix the problem. <code>print type(ax)</code> gives:</p>
  
  <pre><code>&lt;class 'matplotlib.axes.AxesSubplot'&gt;
  </code></pre>
  
  <p>Can anyone point out why my code works in ipython but not a plain python file? Thanks in advance.</p>