0

Following is my code:

import seaborn as sns
df = sns.load_dataset('iris')

The following line gives me a normal violin plot of species vs sepal_length:

sns.violinplot(x = df['species'], y = df['sepal_length'])

The output looks as such

species vs sepal_length

Now, I need to change the color of each plot, that's where I'm stuck Is there a way to do it by staying in seaborn violin_plot and not going into matplotlib or anything?

Sufyan Parkar
  • 171
  • 3
  • 9

1 Answers1

0

The answer to that is to use a simple parameter of seaborn's violin_plot called pallete.

Following is the code for that:

import seaborn as sns
df = sns.load_dataset('iris')
sns.violinplot(x = df['species'], y = df['sepal_length'], palette = ['green', 'blue', 'yellow'])

and BAM ! it's done.

Sufyan Parkar
  • 171
  • 3
  • 9