title: How to add axes to subplots?
body: <p>I have a series of related functions that I plot with <code>matplotlib.pyplot.subplots</code>, and I need to include in each subplot a zoomed part of the corresponding function.</p>
  
  <p>I started doing it like explained <a href="https://stackoverflow.com/questions/13583153/">here</a> and it works perfectly when there is a single graph, but not with subplots. </p>
  
  <p>If I do it with subplots, I only get a single graph, with all the functions inside it. Here is an example of what I get so far:</p>
  
  <pre><code>import numpy as np
  import matplotlib.pyplot as plt
  
  x = np.arange(-10, 10, 0.01)
  sinx = np.sin(x)
  tanx = np.tan(x)
  
  fig, ax = plt.subplots( 1, 2, sharey='row', figsize=(9, 3) )
  
  for i, f in enumerate([sinx, cosx]):
      ax[i].plot( x, f, color='red' )
      ax[i].set_ylim([-2, 2])
  
      axx = plt.axes([.2, .6, .2, .2],)
      axx.plot( x, f, color='green' )
      axx.set_xlim([0, 5])
      axx.set_ylim([0.75, 1.25])
  
  plt.show(fig)
  </code></pre>
  
  <p>That piece of code gives the following graph:</p>
  
  <p><a href="https://i.stack.imgur.com/PD2QD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PD2QD.png" alt="enter image description here"></a></p>
  
  <p><strong>How I can create new axes and plot in each subfigure?</strong></p>