python - How to get x and y coordinates from matplotlib scatter plot using plt.gca()? -


is there way x , y coordinates of scatter plot points matplotlib axes object? plt.plot(), there attribute called data, following code 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' 

import matplotlib.pylab plt  x = [1, 2, 6, 3, 11] y = [2, 4, 10, 3, 2] plt.scatter(x, y) ax = plt.gca() cs = ax.collections[0] cs.set_offset_position('data') print cs.get_offsets() 

output is

[[ 1  2]  [ 2  4]  [ 6 10]  [ 3  3]  [11  2]] 

Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -