title: Missing some minor gridlines in matplotlib after deleting part of data range
body: <p>Executing the following code gives a plot where the last 2 minor grid lines are missing in both x and y. If I remove the section of the code that trims the data or extend the amount of data which is accepted (xylimit) then this can be obviated. Can anyone see what I'm doing wrong?</p>
  
  <pre><code>from __future__ import division
  import numpy as np
  import matplotlib.pyplot as plt
  from pylab import *
  
  l=201
  x=linspace(-l,l,201)
  y=linspace(-l,l,201)
  z=np.random.rand(l,l)
  
  xylimit=100
  
  i=0
  while i&lt;len(x[:]):
       if abs(x[i])&gt;xylimit:
           x=np.delete(x,i,0)
           y=np.delete(y,i,0)
       else:
           i+=1
  i=0
  while i&lt;len(y[:]):
       if abs(y[i])&gt;xylimit:
           x=np.delete(x,i,0)
           y=np.delete(y,i,0)
       else:
           i+=1
  
  z=np.random.rand(len(x),len(x))
  
  xgridlines = getp(gca(), 'xgridlines')
  ygridlines = getp(gca(), 'ygridlines')
  plt.minorticks_on()
  plt.grid(b=True, which='both',linestyle='-')
  
  l=plt.contourf(x,y,z,np.linspace(0,1,255))
  
  plt.show()
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/ILCyK.png" alt="contourplot"></p>