Fix problem with legend if data has NaN's

If data has NaN's and plot has a legend, matplotlib throws a
RuntimeWarning on lines 651-654.
Solution is ignore it.
Merge pull request #3613 from demotu/master

Fix problem with legend if data has NaN's [backport to 1.4.x]