title: Colorbar/plotting issue? "posx and posy should be finite values"
body: <p><strong>The problem</strong></p>
  
  <p>So I have a lat-lon array with <code>6</code> layers (<code>array.size = (192,288,6)</code>) containing a bunch of data ranging in values from nearly <code>0</code> to about <code>0.65</code>. When I plot data from every one of the <code>6</code> layers (<code>[:,:,0]</code>, <code>[:,:,1]</code>, etc.), I have no problems and get a nice map, except for <code>[:,:,4]</code>. For some reason, when I try to plot this 2D array, I get an error message I don't understand, and it only comes up when I try to include a colorbar. If I nix the colorbar there's no error, but I need that colorbar...</p>
  
  <p><strong>The code</strong></p>
  
  <p>Here's the code I use for a different part of the array, along with the resulting plot. Let's go with <code>[:,:,5]</code>.</p>
  
  <pre><code>#Set labels
  lonlabels = ['0','45E','90E','135E','180','135W','90W','45W','0']
  latlabels = ['90S','60S','30S','Eq.','30N','60N','90N']
  
  #Set cmap properties
  bounds = np.array([0,0.001,0.01,0.05,0.1,0.2,0.3,0.4,0.5,0.6])
  boundlabels = ['0','0.001','0.01','0.05','0.1','0.2','0.3','0.4','0.5','0.6']
  cmap = plt.get_cmap('jet')
  norm = colors.PowerNorm(0.35,vmax=0.65) #creates logarithmic scale
  
  #Create basemap
  fig,ax = plt.subplots(figsize=(15.,10.))
  m = Basemap(projection='cyl',llcrnrlat=-90,urcrnrlat=90,llcrnrlon=0,urcrnrlon=360.,lon_0=180.,resolution='c')
  m.drawcoastlines(linewidth=2,color='w')
  m.drawcountries(linewidth=2,color='w')
  m.drawparallels(np.arange(-90,90,30.),linewidth=0.3)
  m.drawmeridians(np.arange(-180.,180.,45.),linewidth=0.3)   
  meshlon,meshlat = np.meshgrid(lon,lat)
  x,y = m(meshlon,meshlat)
  
  #Plot variables
  trend = m.pcolormesh(x,y,array[:,:,5],cmap='jet',norm=norm,shading='gouraud')
  
  #Set plot properties
  #Colorbar
  cbar=m.colorbar(trend, size='5%',ticks=bounds,location='bottom',pad=0.8)
  cbar.set_label(label='Here is a label',size=25)
  cbar.set_ticklabels(boundlabels)
  for t in cbar.ax.get_xticklabels():
      t.set_fontsize(25)
  #Titles &amp; labels
  ax.set_title('Here is a title for [:,:,5]',fontsize=35)
  ax.set_xlabel('Longitude',fontsize=25)
  ax.set_xticks(np.arange(0,405,45))
  ax.set_xticklabels(lonlabels,fontsize=20)
  ax.set_yticks(np.arange(-90,120,30))
  ax.set_yticklabels(latlabels,fontsize=20)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/DTTwg.png" rel="noreferrer"><img src="https://i.stack.imgur.com/DTTwg.png" alt="enter image description here"></a></p>
  
  <p>Now when I use the EXACT same code but plot for <code>array[:,:,4]</code> instead of <code>array[:,:,5]</code>, I get this error.</p>
  
  <pre><code>ValueError                                Traceback (most recent call last)
  /linuxapps/anaconda/lib/python2.7/site-packages/IPython/core/formatters.pyc in __call__(self, obj)
      305                 pass
      306             else:
  --&gt; 307                 return printer(obj)
      308             # Finally look for special method names
      309             method = get_real_method(obj, self.print_method)
  
  [lots of further traceback]
  
  /linuxapps/anaconda/lib/python2.7/site-packages/matplotlib/text.pyc in draw(self, renderer)
      755             posy = float(textobj.convert_yunits(textobj._y))
      756             if not np.isfinite(posx) or not np.isfinite(posy):
  --&gt; 757                 raise ValueError("posx and posy should be finite values")
      758             posx, posy = trans.transform_point((posx, posy))
      759             canvasw, canvash = renderer.get_canvas_width_height()
  
  ValueError: posx and posy should be finite values
  </code></pre>
  
  <p>I have no idea why it's doing this as my code for every other part of the array plots just fine, and they all use the same meshgrid. There are no <code>NaN</code>'s in the array. Also here's the result if I comment out all the code between <code>#Colorbar</code> and <code>#Titles &amp; labels</code></p>
  
  <p><a href="https://i.stack.imgur.com/d7mSg.png" rel="noreferrer"><img src="https://i.stack.imgur.com/d7mSg.png" alt="enter image description here"></a></p>
  
  <p>UPDATE: The problem also disappears when I include the colorbar code but changed the <code>PowerNorm</code> to <code>1.0</code> (<code>norm = colors.PowerNorm(1.0,vmax=0.65)</code>). Anything other than <code>1.0</code> generates the error when the colorbar is included.</p>
  
  <p><strong>The question</strong></p>
  
  <p>What could be causing the <code>posx</code> &amp; <code>posy</code> error message, and how can I get rid of it so I can make this plot with the colorbar included?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>When I run the kernel from scratch, again with the same code (except that I changed the <code>0.6</code> bound to <code>0.65</code>), I get the following warnings in the <code>array[:,:,4]</code> block. I'm not sure if they're related, but I'll include them just in case.</p>
  
  <pre><code>/linuxapps/anaconda/lib/python2.7/site-packages/matplotlib/colors.py:1202: RuntimeWarning: invalid value encountered in power
    np.power(resdat, gamma, resdat)
  
  [&lt;matplotlib.text.Text at 0x2af62c8e6710&gt;,
   &lt;matplotlib.text.Text at 0x2af62c8ffed0&gt;,
   &lt;matplotlib.text.Text at 0x2af62cad8e90&gt;,
   &lt;matplotlib.text.Text at 0x2af62cadd3d0&gt;,
   &lt;matplotlib.text.Text at 0x2af62caddad0&gt;,
   &lt;matplotlib.text.Text at 0x2af62cae7250&gt;,
   &lt;matplotlib.text.Text at 0x2af62cacd050&gt;]
  
  /linuxapps/anaconda/lib/python2.7/site-packages/matplotlib/axis.py:1015:     UserWarning: Unable to find pixel distance along axis for interval padding of ticks; assuming no interval padding needed.
    warnings.warn("Unable to find pixel distance along axis "
  /linuxapps/anaconda/lib/python2.7/site-packages/matplotlib/axis.py:1025:     UserWarning: Unable to find pixel distance along axis for interval padding of ticks; assuming no interval padding needed.
    warnings.warn("Unable to find pixel distance along axis "
  </code></pre>