I am getting this error when setting the s value to an array position, if i leave it like s = 50, it works but do not know the reason:
def Overlay_Points(Image_In_Path, Image_Out_Path, Points_Array):
plt.clf()
im = plt.imread(Image_In_Path)
implot = plt.imshow(im)
for c in range(len(Points_Array)):
if Points_Array[c][3] == 1:
plt.scatter(Points_Array[c][0], Points_Array[c][1], 'g', Points_Array[c][2])
else:
plt.scatter(Points_Array[c][0], Points_Array[c][1], 'r', Points_Array[c][2])
plt.savefig(Image_Out_Path)
plt.close()
return 1
Overlay_Points('Anillo.jpg', 'ejemplo.jpg', [[1000, 1000, 50, 1], [2000, 2000, 100, 0]])
Thanks for the help
CodePudding user response:
As per scatter plot documentation here, the third entry is size and fourth is color. You appear to have written it in reverse. You can either reverse the order or specifically say s=
and c=
. Once I made that change, the code appeared to run fine...
Change the code like this...
if Points_Array[c][3] == 1:
plt.scatter(Points_Array[c][0], Points_Array[c][1], c='g', s=Points_Array[c][2])
else:
plt.scatter(Points_Array[c][0], Points_Array[c][1], c='r', s=Points_Array[c][2])