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

houdinisparks picture houdinisparks · May 28, 2017 · Viewed 7.7k times · Source

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

Answer

a good guy picture a good guy · Jun 23, 2017

Put the thing in brackets:

plt.scatter([X[:,0]],[X[:,1]])