您可以提供一个重复的x值数组来定位两者.
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
data = np.random.randn(200).cumsum()
ax = sns.violinplot(y=data, x=np.full_like(data, 1.5), inner=None, orient='v',
bw_method=.1, fill=True)
sns.stripplot(y=data, x=np.full_like(data, 1), jitter=True, orient='v',
edgecolor='white', linewidth=0.5, color='lightblue', ax=ax)
ax.set_xticks([])
plt.show()
PS:sns.stripplot
的jitter=
参数也可以是改变宽度的值,例如jitter=0.3
.