I'm plotting a list of vectors as a sequence of violin plots. I'd use a pandas dataframe, but the lists are unequal lengths.
This works:
python
g = sns.violinplot (data=res, cut=0, inner='box')
where 'res' is a list of lists (each a vector of floats), where each vector should be turned into a violin. It is.
but the x axis is just labeled '0,1,2...'. Adding the parameter 'names=[0,1,2...]' is silently ignored.
You can use the .set_xticklabels()
method:
ax = sns.violinplot(data=res, cut=0, inner='box')
ax.set_xticklabels(['a','b','c'...])
Example:
import numpy as np, seaborn as sns
res = [i for i in (np.random.randn(3, 25))]
ax = sns.violinplot(data=res, cut=0, inner='box')
ax.set_xticklabels(['a','b','c'])
Results in:
ax = sns.violinplot(data=rescaledX, inner='quartile')
ax.set_xticklabels(bos.columns)
ax.set_title('Distribution of Boston Housing Data Set', fontsize=16);
Violin Plot of Boston Housing Data with Labeled Columns
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