Matplotlib中y = 0处的暗轴线

9

这给我带来了很多网格线,如下所示。

我如何仅为y = 0获取一条深色轴线?

fig, ax1 = subplots(figsize=(3,6))
ax1.yaxis.grid(True, linestyle='-', which='major', color='grey', alpha=0.5)

bound = 20
ylim([-bound,bound])
boxplot(data)

show()

box and whisker plot

1个回答

11
你需要调用 axhline 函数:
axhline(0, color='black')

enter image description here


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接