title: Plot contours for the densest region of a scatter plot
body: <p>I am generating a scatter plot of ~300k data points and am having the issue that it is so over-crowded in some places that no structure is visible - So I had a thought!</p>
  
  <p>I want to have the plot generate a contour plot for the densest parts and leave the less-dense areas with the <code>scatter()</code> data points.</p>
  
  <p>So I was trying to individually compute a nearest-neighbour distance for each of the data points and then when this distance hit a specific value, draw a contour and fill it, then when it hit a much larger value (less dense) just do the scatter...</p>
  
  <p>I have been trying and failing for a few days now, I am not sure that the conventional contour plot will work in this case.</p>
  
  <p>I would supply code but it is so messy and would probably just confuse the issue. And it is so computationally intensive that it would probably just crash my pc if it did work!</p>
  
  <p>Thank you all in advance!</p>
  
  <p>p.s. I have been searching and searching for an answer! I am convinced it is not even possible for all the results it turned up!</p>
  
  <p>Edit: So the idea of this is to see where some particular points lie within the structure of the 300k sample. Here is an example plot, my points are scattered in three diff. colours.
  <img src="https://i.stack.imgur.com/pS2wv.png" alt="My scatter version of the data"></p>
  
  <p>I will attempt to randomly sample 1000 datapoints from my data and upload it as a text file.
  Cheers Stackers. :)</p>
  
  <p>Edit: Hey,
  Here are some sample data 1000 lines - just two columns <code>[X,Y]</code> (or <code>[g-i,i]</code> from plot above) space delimited. Thank you all!
  <a href="https://dl.dropboxusercontent.com/u/59920113/catal_999.txt" rel="noreferrer">the data</a></p>