我需要的是这样的(带有中线):
我尝试过的是这段代码:
exercise = sns.load_dataset("exercise")
g = sns.catplot(x="time", y="pulse", hue="kind", data=exercise, kind="box")
bars = g.axes[0][0].patches
hatches=['//','..','xx','//','..','xx','//','..','xx']
for pat,bar in zip(hatches,bars):
bar.set_hatch(pat)
Run Code Online (Sandbox Code Playgroud)
这只会生成第一个数字。第3-6行的想法来自这个问题。但进入第 3 行的想法axes[0][0]来自于这个问题。
因为 FacetGrid 没有补丁或容器等属性,所以很难将单个图中的影线答案适应分类图,所以我无法弄清楚。