pyplot raises 'x and y must have same first dimension' error, probably because somewhere there are two samevalues for the y