title: How to get a smoothed contour line in matplotlib given non-smooth underlying data
body: <p>I have boolean data on a 2D grid and want to use <code>matplotlib</code> to plot a countour between the areas where the data is <code>True</code> and <code>False</code>.</p>
  <p>However, the separation between these areas is <em>not</em> smooth within the actual data. How can I compute a smoothed countour given this data?</p>
  <p>Here is a minimal example:</p>
  <pre><code>import numpy as np
  import matplotlib.pyplot as plt
  
  # generate some non-smooth example data
  MESHSIZE = 10
  REFINEMENT = 4*MESHSIZE
  x = np.linspace(-MESHSIZE, MESHSIZE, REFINEMENT)
  xv, yv = np.meshgrid(x, x)
  xvf = xv.reshape(-1)
  yvf = yv.reshape(-1)
  
  
  def choppy_circle(x, y):
      inner = x.astype(int)**2+y.astype(int)**2 &lt; 10.0
      return inner
  
  
  # consider this the *actual* data given to me as-is
  my_x = xvf
  my_y = yvf
  my_z = choppy_circle(xvf, yvf)
  
  # need to visualize the contour that separates areas where
  # my_z is True/False
  plt.tricontour(my_x, my_y, my_z, levels=np.array([1.0-1e-3]))
  plt.scatter(xv, yv, s=0.1)
  plt.show()
  </code></pre>
  <p>This produces the following plot, which is faithful to the data, but not what I'm looking for:</p>
  <p><a href="https://i.stack.imgur.com/6PBXkm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6PBXkm.png" alt="enter image description here" /></a></p>
  <p>How can I use the data given in <code>my_x</code>, <code>my_y</code> and <code>my_z</code> to construct a smoothed contour around the domain where <code>my_z</code> is <code>True</code>?</p>
  <p>Something like this:</p>
  <p><a href="https://i.stack.imgur.com/7GRXzm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7GRXzm.png" alt="enter image description here" /></a></p>