title: How to add a single legend label for a set of boxplots?
body: <p>Is there a better way of adding <strong>a single label</strong> to a legend for a <strong>set of boxplots</strong>?</p>
  
  <p>Below is a simple worked example that gives the desired result. This is done my creating an invisible line (<code>alpha=0</code>) with the desired label, then   changing the alpha via the <code>legendHandles</code>. however can a single label for all the boxplots just be passed to <a href="https://seaborn.pydata.org/generated/seaborn.boxplot.html" rel="nofollow noreferrer"><code>sns.boxplot()</code></a>? </p>
  
  <pre><code>import seaborn as sns
  import pandas as pd
  import numpy as np
  import matplotlib.pyplot as plt
  
  # Get the tips dataset and select a subset as an example
  tips = sns.load_dataset("tips")
  variable_to_bin_by = 'tip'
  binned_variable = 'total_bill'
  df = tips[ [binned_variable,  variable_to_bin_by] ]  
  
  # Group the data by a list of bins
  bins = np.array([0, 1, 2, 3, 4])
  gdf = df.groupby( pd.cut(df[variable_to_bin_by].values, bins ) )
  data = [ i[1][binned_variable].values for i in gdf]
  df = pd.DataFrame( data, index = bins[:-1])   
  
  # Plot the data (using boxplots to show spread of real values)
  fig, ax = plt.subplots()
  ax = sns.boxplot( data=df.T, ax=ax, color='k')
  
  # Create hidden line with the extra label (to give label to boxplots)
  x = np.range(10)
  plt.plot(x, x, label='REAL DATA', color='k', alpha=0)
  
  # Now plot some "model fit" lines
  models = {'model1': bins+10, 'model2': bins+10*1.5, 'model3': bins*10}
  for key in sorted( models.keys() ):
      plt.plot( bins, models[key], label=key )
  
  # Add a legend
  leg = plt.legend()
  
  # Update line visibility (alpha)
  for legobj in leg.legendHandles:
          legobj.set_alpha( 1 )
  
  # Show the plot
  plt.show()
  </code></pre>
  
  <p>Although this gives the desired result (as below), my question is whether there a better way?</p>
  
  <p><a href="https://i.stack.imgur.com/EiaOt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EiaOt.png" alt="Success!"></a></p>