我在 Matplotlib 中绘制了一系列点。这是我的代码:
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()
这给了我这个情节: 情节 1
当我在上面的代码片段中取消注释时ys.reverse()
,我希望图像垂直翻转,但我却得到了这个,这是完全错误的:
我该如何解决这个问题并使情节正确翻转?注意:我不想要这样的解决方案plt.gca.invert_yaxis()
- 我想要更正点数组。
谢谢,Vineeth
Helenr
狐的传说
相关分类