Use the tab10 palette:
sns.color_palette("tab10")
or in your case:
sns.violinplot(..., palette="tab10")
EDIT:
You also need saturation=1:
sns.violinplot(..., palette="tab10", saturation=1)
Answer from BigBen on Stack OverflowUse the tab10 palette:
sns.color_palette("tab10")
or in your case:
sns.violinplot(..., palette="tab10")
EDIT:
You also need saturation=1:
sns.violinplot(..., palette="tab10", saturation=1)
The default matplotlib color palette is tab10, as shown in the "Qualitative" colormaps on this documentation page. I think the easiest way to use it would be to set the global colormap to tab10 (or use tab20 if you have more than 10 items) using sns.set_palette. By doing that, every seaborn figure you make in that script that uses a discrete colormap will use the tab10 colormap.
Edit: As commented by @JohanC, you also need to set saturation=1 when creating the plots. As the documentation states regarding the saturation parameter:
Proportion of the original saturation to draw colors at. Large patches often look better with slightly desaturated colors, but set this to
1if you want the plot colors to perfectly match the input color.
Example (adapted from the seaborn.violinplot documentation):
import matplotlib.pyplot as plt
import seaborn as sns
plt.close("all")
sns.set_palette("tab10") # or "tab20"
df = sns.load_dataset("titanic")
fig, ax = plt.subplots()
sns.violinplot(data=df, x="age", y="class", ax=ax, saturation=1)
fig.tight_layout()

