title: Plotting contour lines that show percentage of particles
body: <p>What I am trying to produce is something similar to this plot:</p>
  
  <p><a href="https://i.stack.imgur.com/Xqs43.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Xqs43.png" alt="enter image description here"></a></p>
  
  <p>Which is a contour plot representing 68%, 95%, 99.7% of the particles comprised in two data sets.</p>
  
  <p>So far, I have tried to implement a gaussain KDE estimate, and plotting those particles gaussians on a contour.</p>
  
  <p>Files are added here <a href="https://www.dropbox.com/sh/86r9hf61wlzitvy/AABG2mbmmeokIiqXsZ8P76Swa?dl=0" rel="nofollow noreferrer">https://www.dropbox.com/sh/86r9hf61wlzitvy/AABG2mbmmeokIiqXsZ8P76Swa?dl=0</a></p>
  
  <pre><code>from scipy.stats import gaussian_kde
  import matplotlib.pyplot as plt
  import numpy as np
  
  # My data
  x = RelDist
  y = RadVel
  
  # Peform the kernel density estimate
  k = gaussian_kde(np.vstack([RelDist, RadVel]))
  xi, yi = np.mgrid[x.min():x.max():x.size**0.5*1j,y.min():y.max():y.size**0.5*1j]
  zi = k(np.vstack([xi.flatten(), yi.flatten()]))
  
  
  
  fig = plt.figure()
  ax = fig.gca()
  
  
  CS = ax.contour(xi, yi, zi.reshape(xi.shape), colors='darkslateblue')
  plt.clabel(CS, inline=1, fontsize=10)
  
  ax.set_xlim(20, 800)
  ax.set_ylim(-450, 450)
  ax.set_xscale('log')
  
  plt.show()
  </code></pre>
  
  <p>Producing this:</p>
  
  <p><img src="https://i.stack.imgur.com/F1Cqx.png" alt="enter image description here">]<a href="https://i.stack.imgur.com/F1Cqx.png" rel="nofollow noreferrer">2</a></p>
  
  <p>Where 1) I do not know how to necessarily control the bin number in gaussain kde, 2) The contour labels are all zero, 3) I have no clue on determining the percentiles.</p>
  
  <p>Any help is appreciated.</p>