Matplotlib:在其他图形元素后面绘制网格线 [英] Matplotlib: draw grid lines behind other graph elements

查看:781
本文介绍了Matplotlib:在其他图形元素后面绘制网格线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Matplotlib中,我制作了如下网格线:

In Matplotlib, I make dashed grid lines as follows:

fig = pylab.figure()    
ax = fig.add_subplot(1,1,1)
ax.yaxis.grid(color='gray', linestyle='dashed')

但是,我无法了解如何(或者即使有可能)将网格线绘制在其他图形元素(如条形图)后面。改变添加网格的顺序与添加其他元素的顺序没有区别。

however, I can't find out how (or even if it is possible) to make the grid lines be drawn behind other graph elements, such as bars. Changing the order of adding the grid versus adding other elements makes no difference.

是否有可能使网格出现在其他所有内容之后?

Is it possible to make it so that the grid lines appear behind everything else?

推荐答案

据此 - http://old.nabble .com / axis-elements-and-zorder-td6119088.html - 您可以使用 Axis.set_axisbelow(True)

According to this - http://old.nabble.com/axis-elements-and-zorder-td6119088.html - you can use Axis.set_axisbelow(True)

(我目前首次安装matplotlib,所以不知道这是否正确 - 我只是通过使用google搜索matplotlib z order grid找到它 - z order通常用于描述这种东西(z是轴离开页面))

(I am currently installing matplotlib for the first time, so have no idea if that's correct - I just found it by googling "matplotlib z order grid" - "z order" is typically used to describe this kind of thing (z being the axis "out of the page"))

这篇关于Matplotlib:在其他图形元素后面绘制网格线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆