0
X = np.array([1,2,3,4,5])    
Y = np.array([1,2,3,4,5])

I need to plot with scatter these point ==> (1,1),(1,2),(1,3),...,(5,3),(5,4),(5,5)

If we try:

X = np.array([1,2,3,4,5])   
Y = np.array([1,2,3,4,5])      
fig = plt.figure()
ax = fig.add_subplot(111)
ax.scatter(X,Y)
plt.show()

result is only these point ==> (1,1),(2,2),(3,3),(4,4),(5,5)

Specifically, I am trying to mark all possible (x, y) binaries that can be created from the given x and y binaries

DavidG
  • 24,279
  • 14
  • 89
  • 82
Enes
  • 23
  • 5

2 Answers2

3

You're looking for the meshgrid function: https://numpy.org/doc/1.18/reference/generated/numpy.meshgrid.html

A,B = np.meshgrid(X,Y)                                                                                      
plt.scatter(A,B)                                                    
imochoa
  • 736
  • 4
  • 8
1
all_pts_x, all_pts_y = np.meshgrid(X, Y)
ax.scatter(all_pts_x, all_pts_y)

enter image description here

alani
  • 12,573
  • 2
  • 13
  • 23