Seaborn Violinplot change order of hue
--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Popsicle Puzzles
--
Chapters
00:00 Seaborn Violinplot Change Order Of Hue
00:41 Accepted Answer Score 10
00:57 Thank you
--
Full question
https://stackoverflow.com/questions/5937...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #pandas #seaborn
#avk47
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Popsicle Puzzles
--
Chapters
00:00 Seaborn Violinplot Change Order Of Hue
00:41 Accepted Answer Score 10
00:57 Thank you
--
Full question
https://stackoverflow.com/questions/5937...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #pandas #seaborn
#avk47
ACCEPTED ANSWER
Score 10
You need to set hue_order:
import pandas as pd
import seaborn as sns
import numpy as np
df = pd.DataFrame({'my_bool': pd.Series(np.random.choice([True,False],20),dtype='bool'),
'value': pd.Series(np.random.choice(200,20),dtype='int'),
'my_group': np.random.choice(['A','B'],20)})
sns.violinplot(x='my_group',data=df,y='value',hue='my_bool', hue_order= [True, False], split=True, palette = {True:'blue', False:'red'})