Matplotlib:在其他图形元素后面绘制网格线

编程入门 行业动态 更新时间:2024-10-28 09:20:43
本文介绍了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 / axis-elements-and-zorder-td6119088.html - 您可以使用 Axis.set_axisbelow(True)

According to this - old.nabble/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:在其他图形元素后面绘制网格线

本文发布于:2023-07-18 00:51:10,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:网格   图形   元素   Matplotlib

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!