title: How to exclude series from displaying in the matplotlib legend?
body: <p>I have a loop going through a big dataset storing the data in various lists and plotting them at the end. However, some of the series are only contain <code>Null</code> values and don't want them to include in the legend. Is there any way I can exclude series from a legend? This is a simple example that <code>z</code> contains only <code>Null</code>s.</p>
  
  <pre><code>import numpy as np
  import matplotlib.pyplot as plt
  
  x = np.arange(1, 5)
  y = 1/x
  z = [np.nan, np.nan, np.nan, np.nan]
  
  plt.plot(x,y, label = 'x data')
  plt.plot(x,z, label = 'z data')
  
  plt.legend()
  plt.show()
  </code></pre>