Om Rastogi
Om Rastogi

Reputation: 1005

cannot unpack non-iterable PathCollection object

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

Upvotes: 2

Views: 11496

Answers (1)

Sadra Sabouri
Sadra Sabouri

Reputation: 309

Chage 4th line to:

scatter = ax.scatter(x_arr,y_arr)

It'll solve your issue.

scatter just returns a object.

Upvotes: 5

Related Questions