What I want to achieve is to conditionally color my scatter plot. I followed this post, but I get TypeError: len() of unsized object
. I'm doing the following
for i in range(n_cells):
col = np.where(cell_list[i].m_n == 1, 'g', 'k')
plt.scatter(cell_list[i].x, cell_list[i].y, c = col, alpha = 0.5, s = 2)
cell_list
is an array of cell
s, which is a user-defined object. I have checked and ensured that col
is an array of g
and k
of the correct size. Moreover, if you change c = col
to c = 'b'
for example, the plot works correctly. I'm relatively new to Python, so I cannot find what the issue is.