title: Access matplotlib objects of scatter plot
body: <p>Given a matplotlib 2.0.0 scatter plot with few points, I want to annotate some of the points without overlapping other points. For the annotation, I use <a href="https://github.com/Phlya/adjustText" rel="nofollow noreferrer">adjustText</a> which takes an optional list of matplotlib objects (with the .get_window_extent() method) to avoid. But I could not yet find out how to get those objects for the points in the scatter plot.</p>
  
  <p>How can I get a list of (point) objects having <code>.get_window_extent()</code> from the scatter plot?</p>
  
  <p>Consider for example:</p>
  
  <pre><code>import matplotlib.pyplot as plt
  from adjustText import adjust_text
  x,y = [1,2,3,4,5],[2,4,6,8,10]
  scatter = plt.scatter(x,y)
  annotations = []
  for x_i, y_i in zip(x[:-3],y[:-3]):
      annotations.append(plt.text(x_i,y_i, 'foobar'))
  adjust_text(annotations, add_objects=scatter)
  </code></pre>
  
  <p>Using <code>add_objects=</code></p>
  
  <ul>
  <li><code>scatter</code> throws a <code>TypeError: 'PathCollection' object is not iterable</code></li>
  <li><code>scatter.get_paths()</code> throws a <code>AttributeError: 'Path' object has no attribute 'get_window_extent'</code></li>
  </ul>