1

I am using Seaborn's FacetGrid to combine many plots in one figure and I want to remove the legend title. For instance, in the example below, I want to remove the title "sex".

import matplotlib.pyplot as plt
import seaborn as sns

tips = sns.load_dataset('tips')

g = sns.FacetGrid(tips, col= 'day')
g.map(sns.lineplot, 'total_bill', 'tip', 'sex', ci = False)    
g.add_legend()

enter image description here

I am aware of the discussion how to change the title in, e.g., How can I change the Seaborn FacetGrid's legend title? However, I have not seen how to remove the legend title

matnor
  • 479
  • 1
  • 5
  • 17

1 Answers1

1

I tried using the hack provided in this answer by ImportanceOfBeingErnest and it works for your purpose

tips = sns.load_dataset('tips')
tips.columns = [n if n != "sex" else "" for n in tips.columns]

g = sns.FacetGrid(tips, col= 'day')
g.map(sns.lineplot, 'total_bill', 'tip', '', ci = False)    
leg = g.add_legend()

enter image description here

Sheldore
  • 37,862
  • 7
  • 57
  • 71
  • Great, that works. Seems like there should be a non-hacking way of doing it, but I guess not. – matnor Feb 14 '20 at 11:50