此问题在此处已有答案:
How to add hatches to boxplots with sns.boxplot or sns.catplot(1个答案)
2天前关闭。
在下面的图表中,我想添加影线(“/”)只到“休息”类别中的两个boxlot。我会很高兴,如果你的帮助
我添加了以下示例代码:
import seaborn as sns
exercise = sns.load_dataset("exercise")
df1=exercise.loc[(exercise["diet"]=="low fat"),:]
df2=exercise.loc[(exercise["diet"]=="no fat"),:]
fig, axes = plt.subplots(1, 2)
ax1=sns.boxplot(x='kind', y='pulse', orient='v', ax=axes[0],data=df1, showfliers=False)
ax2= sns.boxplot(x='kind', y='pulse', orient='v', ax=axes[1],data=df2, showfliers=False)
1条答案
按热度按时间rsl1atfo1#
您可以迭代xticks标签和面片,并仅为
rest
设置影线:输出: