title: How to control the legend in Seaborn - Python
body: <p>I am trying to find guidance on how to control and customize the legend in Seaborn plots but I can not find any.</p>
  
  <p>To make the issue more concrete I provide a reproducible example:</p>
  
  <pre><code>surveys_by_year_sex_long
  
      year    sex wgt
  0   2001    F   36.221914
  1   2001    M   36.481844
  2   2002    F   34.016799
  3   2002    M   37.589905
  
  %matplotlib inline
  from matplotlib import *
  from matplotlib import pyplot as plt
  import seaborn as sn
  
  sn.factorplot(x = "year", y = "wgt", data = surveys_by_year_sex_long, hue = "sex", kind = "bar", legend_out = True,
               palette = sn.color_palette(palette = ["SteelBlue" , "Salmon"]), hue_order = ["M", "F"])
  plt.xlabel('Year')
  plt.ylabel('Weight')
  plt.title('Average Weight by Year and Sex')
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/sswIj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sswIj.png" alt="enter image description here"></a></p>
  
  <p>In this example I would like to be able to define M as Male and F as Female and instead of sex to have Sex as title of the legend.</p>
  
  <p>Your advice will be appreciated.</p>