Fix problem with legend if data has NaN's

If data has NaN's and the plot a legend with parameter 'best', matplotlib throws the following RuntimeWarning:

...\matplotlib\transforms.py:651: RuntimeWarning: invalid value encountered in sign
  dx0 = np.sign(vertices[:, 0] - x0)
...\matplotlib\transforms.py:652: RuntimeWarning: invalid value encountered in sign
  dy0 = np.sign(vertices[:, 1] - y0)
...\matplotlib\transforms.py:653: RuntimeWarning: invalid value encountered in sign
  dx1 = np.sign(vertices[:, 0] - x1)
...\matplotlib\transforms.py:654: RuntimeWarning: invalid value encountered in sign
  dy1 = np.sign(vertices[:, 1] - y1)

The following code reproduces this RuntimeWarning:
plt.plot([1,2,np.nan,4,5], label='test')
plt.legend(loc='best')

The solution is to check for NaN's in data and delete those rows, as suggested.