The np.asmatrix()
just convert an iterable to a matrix, when applicable. So:
trans = np.asmatrix(data.T)
np.all( data == trans.T )
should always give True
The problem with the different plots is that in matplotlib.axes.Axes.scatter
the ravel()
is executed in the numpy.ma
(Masked Arrays) module. Here, despite data==trans.T
, np.ma.ravel(trans[0,:])
returns a matrix instead of a flattened array. To fix that you can call np.ravel()
, that works for non-masked arrays. I opened this issue in GitHub to report this, which is possibly a bug...
The result will be:
fig, axs = mp.subplots(nrows=1, ncols=2, sharey=True )
axs[0].scatter(data[:, 0], data[:, 1])
trans = np.asmatrix(data.T)
axs[1].scatter( np.ravel(trans[0,:]), np.ravel(trans[1,:]) )
fig.tight_layout()
giving you this: