In the Seaborn's FacetGrid based lineplot, would like to change the label title. It seemed like a simple thing, but it turned out to be a hairy task
tips = sns.load_dataset("tips")
g = sns.FacetGrid(tips, col= 'day', legend_out= True,)
g.map(sns.lineplot, 'total_bill', 'tip', 'sex', 'time',
ci = False)
g.fig.legend()
I wanted to change the label title to 'gender' from 'sex' by adding 'title' argument. But it turns out that become a headline on top the existing title
g.add_legend(title = 'Gender')
legend title 'sex' with headline 'Gender'
I also tried to access the fig.legend to change the text, but now it shows multiple legends, probably due to the multi-faceted plots.
l = g.fig.legend()
l.texts[0].set_text('Gender')
legend title 'Gender', however, with multiple legends
I am sure there may be a 'hacky' way to change the name by changing the variable names in the data or so, but I am wondering whether there is a way to simply replace the Seabron FacetGrid's legend title or, if it is not possible, add the title through 'fig.legend' while showing single relevant legend. Many thanks!