matplotlib.scatter() not working with Numpy on Python 3.6
Use np.reshape:
import numpy as np
t1 = np.array([[1,2,3,4,5,6] , [7,8,9,10,11,12]])
t1_single = np.reshape(t1, -1)
print(t1.shape)
print(t1_single.shape)
Output:
(2, 6)
(12,)
plt.scatter(X[:, 0], X[:, 1], s=40, c=T, cmap=plt.cm.Spectral)
In this function, c requires 1-D array, As mentioned in above answer, use T.ravel
or T.reshape(400,)
c
requires a single dimensional array.
T.ravel()
should do the trick.
You can also use c=np.squeeze(T)
.
I think the problem here is actually part of a bigger python/numpy problem - which is it's inability to infer the correct usage of 1D arrays. This wastes ton of times coding and debugging.