How can you change the legend labels on a seaborn FacetGrid using barplots and boxplots?
With scatterplots, you can do this easily:
tips = sns.load_dataset('tips')
g = sns.FacetGrid(data=tips, col='time')
g.map_dataframe(sns.scatterplot, x='total_bill', y='tip', hue='sex')
plt.legend(labels=['Men', 'Women'])
However, the same code using boxplots removes the color patches from the legend:
g = sns.FacetGrid(data=tips, col='time')
g.map_dataframe(sns.boxplot, x='smoker', y='tip', hue='sex')
plt.legend(labels=['Men', 'Women'])
Unlike barplot itself, the FacetGrid has no legend_
property, so existing solutions for barplots like this don't easily apply.
How do you modify the legend labels without removing the color patches?