title: Python Matplotlib - Filling Area Between Two Concentric Circles
body: <p>I'm drawing the following plot using <code>Matplotlib</code>:</p>
  
  <pre><code>import matplotlib.pyplot as mlp
  import numpy.linalg as npl
  
  def ploteig(self, erg:bool) -&gt; None:
  
      theta = np.arange(start=0, stop=2.0*np.pi, step=0.01)
      r = np.ones(len(theta))
  
      values, _ = npl.eig(self._p)
      values = values.astype(complex)
  
      x_unit_circle = r * np.cos(theta)
      y_unit_circle = r * np.sin(theta)
  
      x_eigenvalues = np.unique(np.append(values, np.complex(1.0)))
      y_eigenvalues = np.zeros(len(x_eigenvalues))
  
      has_slem = False
  
      if erg:
          values_abs = np.sort(np.abs(values))
          values_ct1 = np.isclose(values_abs, 1.0)
          if not np.all(values_ct1):
              mu = values_abs[~values_ct1][-1]
              if not np.isclose(mu, 0.0):
                  r *= mu;
                  x_slem_circle = r * np.cos(theta)
                  y_slem_circle = r * np.sin(theta)
                  has_slem = True
  
      fig, ax = mlp.subplots()
      ax.plot(x_unit_circle, y_unit_circle, color='red', linestyle='-', linewidth=3)
      ax.plot(x_eigenvalues, y_eigenvalues, color='blue', linestyle='None', marker='*', markersize=10)
  
      if has_slem:
          ax.plot(x_slem_circle, y_slem_circle, color='red', linestyle='--', linewidth=1)
  
      ax.grid(True)
      ax.set_aspect('equal', 'datalim')
  
      mlp.show()
  </code></pre>
  
  <p>When <code>has_slem</code> is <code>True</code>, then the slem circle is always smaller than the unit circle, hence the plot produces two concentric circles where the outer circle is given by <code>(x_unit_circle,y_unit_circle)</code>  and the inner circle is given by <code>(x_slem_circle,y_slem_circle)</code>.</p>
  
  <p>What I would like to do is to fill the area between the two circles with a light red color. This is what I tried so far:</p>
  
  <pre><code>if has_slem:
      ax.plot(x_slem_circle, y_slem_circle, color='red', linestyle='--', linewidth=1)
      ax.fill_between(x_unit_circle, y_unit_circle, -y_unit_circle, color="red", alpha=0.2)
      ax.fill_between(x_slem_circle, y_slem_circle, -y_slem_circle, color="white")
  </code></pre>
  
  <p>But this approach has two problems:</p>
  
  <ol>
  <li>If the axes color is changed, the second <code>fill_between</code> call would produce a wrong fill based on <code>white</code> color.</li>
  <li>The filled area looks a little bit misaligned with respect to the inner circle (there is a small white gap), as you can see on the screenshot below.</li>
  </ol>
  
  <p><a href="https://i.stack.imgur.com/fkaRE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fkaRE.png" alt="Plot"></a></p>
  
  <p>So, here comes my question: is there a better and more precise approach for filling the area between the two circles that allows me to bypass both problems?</p>
  
  <p>On a totally unrelated note: is it ok to call <code>mlp.show()</code> inside the function? I don't know what are the best practices here... maybe it's better to return the figure handle and let the consumer decide when to pop it up?</p>