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

0

2 Answers 2

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)                                                    
Sign up to request clarification or add additional context in comments.

3 Comments

thx for answer , can we print all these (x,y) variables ?
Sure @EnesA, just do: all_pnts = np.stack((A,B), axis=2).reshape(-1,2)
thx for help :D
1
all_pts_x, all_pts_y = np.meshgrid(X, Y)
ax.scatter(all_pts_x, all_pts_y)

enter image description here

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.