Please, refer to this question in StackOverflow:
http://stackoverflow.com/q/17189313/832621
where the user was trying to compare two plots that should be identical, and the solution was that in pyplot.scatter the np.ma.ravel() does not convert a 1xN matrix to a 1-D array with length N. But if we do np.ravel() instead of np.ma.ravel() it works...