I have an array of points that I am plotting in Matplotlib. Here is my code:
masked = r['masks']
fig=plt.figure()
ax2=fig.add_axes([0,0,1,1])
colors = ['b', 'g', 'r', 'c', 'm','y']
for idx in range(masked.shape[2]):
array = masked[:,:,idx]
xs = []
ys = []
for i in range(len(array)):
for j in range(len(array[0])):
if array[i][j] == True:
xs.append(j)
ys.append(i)
# ys.reverse()
ax2.scatter(xs, ys, color=str(colors[idx]))
plt.show()
And that gives me this plot: PLOT 1
When I then uncomment the ys.reverse()
in the code snippet above, I expect the image to be vertically flipped, but instead I get this, which is completely wrong:
How can I fix this and make the plot correctly flipped? NOTE: I do not want a solution such as plt.gca.invert_yaxis()
- I want the points arrays to be corrected.
Thanks, Vineeth