I make several plots my data using seaborn's displot. I cutomise the palette using the dictionary:
my_palette = {'car': 'b', 'foot':'k', 'metro':'c', 'bus':'r', 'bike':'y'} # values of hue
And then plot like so:
# fig customisation omitted for brevity
sns.displot(df1, x='distance', kind='ecdf', hue='mode', log_scale=True, palette=my_palette,)
Giving:
But then when I plot the next figure, the legend order change (as python dictionary isn't ordered), like this one:
sns.displot(df2, x='distance', kind='ecdf', hue='mode', log_scale=True, palette=my_palette,)
Which gives:
I am wondering if there's a way to maintained a defined ordering, such as foot, bike, bus, car, metro