cannot unpack non-iterable PathCollection object

Viewed 5881
fig,ax = plt.subplots()
ax.set_xlim(0,500)
ax.set_ylim(0,500)
scatter, = ax.scatter(x_arr,y_arr)
plt.show()

In the scatter statement, the program is rising this error. I don't understand what may be the problem.

---
TypeError                                 Traceback (most recent call last)
<ipython-input-26-b70b84828456> in <module>
      6 ax.set_xlim(0,500)
      7 ax.set_ylim(0,500)
----> 8 scatter, = ax.scatter(x_arr,y_arr)
      9 plt.show()

TypeError: cannot unpack non-iterable PathCollection object
1 Answers

Chage 4th line to:

scatter = ax.scatter(x_arr,y_arr)

It'll solve your issue.

scatter just returns a object.

Related