Is there a way to get the x and y coordinates of scatter plot points from a Matplotlib Axes object? For plt.plot()
, there is an attribute called data
, but the following code does not work:
x = [1, 2, 6, 3, 11]
y = [2, 4, 10, 3, 2]
plt.scatter(x, y)
print(plt.gca().data)
plt.show()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-30-9346ca31279c> in <module>()
41 y = [2, 4, 10, 3, 2]
42 plt.scatter(x, y)
---> 43 print(plt.gca().data)
44 plt.show()
AttributeError: 'AxesSubplot' object has no attribute 'data'