Q:

python 3 scatter plot gives "ValueError: Masked arrays must be 1-D" even though i am not using any masked array

I am trying to plot a scatter plot using the .scatter method below. Here
ax.scatter(X[:,0], X[:,1], c = colors, marker = 'o', s=80, edgecolors = 'none')
with the input/args classes below:
X[:,0]] type:  <class 'numpy.matrixlib.defmatrix.matrix'>
X[:,1]] type:  <class 'numpy.matrixlib.defmatrix.matrix'>
colors type:  <class 'list'>
however python is throwing a value error as seen here:
error image

A:

Put the thing in brackets:
plt.scatter([X[:,0]],[X[:,1]])

A:

My experience with this is because your X is a numpy matrix.
Essentially, whenever you try and isolate a row from a matrix, it returns another matrix. Numpy seems to have a constraint that matrices must be 2 dimensional, so it can't tell that it's a 1-d array, and can't mask it (hence the Masked arrays must be 1-D error)
The solution for me was to simply "cast" X to a numpy.array by doing:
X = np.array(X)
ax.scatter(X[:,0], X[:,1], c = colors, marker = 'o', s=80, edgecolors = 'none')

