在Seaborn箱图中不尊重hspan zorder

时间:2020-01-28 00:04:13

标签: seaborn boxplot

尽管有明显的zorder参数相反,我的axhspan区域仍在箱形图的顶部。

我对matplotlib中的zorder的理解(和过去的历史)是较小的数字应导致背景位置,较大的数字应向“前部”绘图。但是我在Seaborn方面没有很多经验。当我查看seaborn和matplotlib文档时,看起来还可以,但是情节却相反:

enter image description here

我的代码:

fig, ax = plt.subplots(figsize=(18,5))
ax = sns.boxplot(x='ID_new',y='A',data=in_df,zorder=10)
plt.axhspan(5,15,zorder=1)
plt.show()

也许我需要以不同的方式调用轴吗?

欢呼

1 个答案:

答案 0 :(得分:0)

zorder更改为-1

fig, ax = plt.subplots(figsize=(18,5))
ax = sns.boxplot(x='ID_new',y='A',data=in_df,zorder=10)
plt.axhspan(5,15,zorder=-1)
plt.show()