I tried violin
plot in Seaborn with different colors for each violin as:
sns.violinplot(x='type', y='den', data=mydf, ax=axes[0], color=['red','blue','yellow'])
however I got:
ValueError: to_rgb: Invalid rgb arg "('red', 'blue', 'yellow')" could not convert string to float: red
I think you should use the palette
keyword:
color : matplotlib color, optional
Color for all of the elements, or seed for light_palette() when using hue nesting.
palette : seaborn color palette or dict, optional
Colors to use for the different levels of the hue variable. Should be something that can be interpreted by color_palette(), or a dictionary mapping hue levels to matplotlib colors.
import seaborn as sb
import numpy as np
data = np.random.random([100,4])
sb.violinplot(data=data, palette=['r','g','b','m'])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With