title: How do I draw a grid onto a plot in Python?
body: <p>I just finished writing code to make a plot using <a href="https://en.wikipedia.org/wiki/Matplotlib#Comparison_with_MATLAB" rel="noreferrer">pylab</a> in Python and now I would like to superimpose a grid of 10x10 onto the scatter plot. How do I do that?</p>
  
  <p>My current code is the following:</p>
  
  <pre><code>x = numpy.arange(0, 1, 0.05)
  y = numpy.power(x, 2)
  
  fig = plt.figure()
  ax = fig.gca()
  ax.set_xticks(numpy.arange(0, 1, 0.1))
  ax.set_yticks(numpy.arange(0, 1., 0.1))
  plt.scatter(x, y)
  plt.show()
  </code></pre>
  
  <p>And its output is:</p>
  
  <p><a href="https://i.stack.imgur.com/P8BYl.png" rel="noreferrer"><img src="https://i.stack.imgur.com/P8BYl.png" alt="Without grid"></a></p>
  
  <p>What I would like is the following output:</p>
  
  <p><a href="https://i.stack.imgur.com/96Z8h.png" rel="noreferrer"><img src="https://i.stack.imgur.com/96Z8h.png" alt="With grid"></a></p>
  
  <p>EDIT: Added an exemple, based on Andrey Sobolev's answer</p>