在Matplotlib中,我按如下所示制作虚线网格:
fig = pylab.figure()
ax = fig.add_subplot(1,1,1)
ax.yaxis.grid(color='gray', linestyle='dashed')
但是,我无法找出如何(甚至可能)在其他图形元素(如条形图)后面绘制网格线。更改添加网格的顺序与添加其他元素的顺序没有区别。
是否有可能使网格线出现在其他所有内容的后面?
最佳答案
根据此-http://matplotlib.1069221.n5.nabble.com/axis-elements-and-zorder-td5346.html-您可以使用Axis.set_axisbelow(True)
(我目前是第一次安装matplotlib,所以不知道这是否正确-我只是通过谷歌搜索“matplotlib z顺序网格”找到它的-通常使用“z顺序”来描述这种情况(z为轴“页面外”))
关于python - Matplotlib:在其他图形元素后面绘制网格线,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/1726391/