I want to change the section headings of my plot legend. For the example below they read: 'smoker' and 'time' but let's say I want them to read 'Smoker' and 'Time of Day' respectively.
import matplotlib.pyplot as plt
import seaborn as sns
tips=sns.load_dataset('tips')
sns.relplot(
data=tips,
x='total_bill', y='tip', hue='smoker', style='time'
)
plt.show()
Any tips?
Edits
Thanks for linking: How to edit a seaborn legend title and labels for figure-level functions
I had only skimmed through it. After spending some more time with it, it still hasn't answered my question. The main difference being I want to change the subtitle values within a legend, rather than the legend title or the label values.
import matplotlib.pyplot as plt
import seaborn as sns
tips=sns.load_dataset('tips')
g = sns.relplot(
data=tips,
x='total_bill', y='tip', hue='smoker', style='time',
facet_kws={'legend_out': True}
)
# can only set the title of the entire legend, not the subtitles
g._legend.set_title('Legend')
plt.show()
If a diagram is more helpful:
red = what I want to change (not answered by How to edit a seaborn legend title and labels for figure-level functions)
yellow = what is answered by How to edit a seaborn legend title and labels for figure-level functions