如何在 seaborn 小提琴情节上添加舱口?
How to add hatches on seaborn violin plot?
如果我这样做:
import seaborn as sns
tips = sns.load_dataset("tips")
ax = sns.violinplot(x="day", y="total_bill", data=tips)
如何通过不同的影线来改变颜色?
我尝试了与箱线图相同的方法,但没有成功。
IIUC:
import seaborn as sns
import matplotlib as mpl
tips = sns.load_dataset("tips")
hatch = ['/','\','+','o']
ihatch = iter(hatch)
ax = sns.violinplot(x="day", y="total_bill", data=tips, color='g')
_ = [i.set_hatch(next(ihatch)) for i in ax.get_children() if isinstance(i, mpl.collections.PolyCollection)]
输出:
如果我这样做:
import seaborn as sns
tips = sns.load_dataset("tips")
ax = sns.violinplot(x="day", y="total_bill", data=tips)
如何通过不同的影线来改变颜色? 我尝试了与箱线图相同的方法,但没有成功。
IIUC:
import seaborn as sns
import matplotlib as mpl
tips = sns.load_dataset("tips")
hatch = ['/','\','+','o']
ihatch = iter(hatch)
ax = sns.violinplot(x="day", y="total_bill", data=tips, color='g')
_ = [i.set_hatch(next(ihatch)) for i in ax.get_children() if isinstance(i, mpl.collections.PolyCollection)]
输出: