Python使用matplotlib.pyplot as plt绘图图层优先级问题
更新时间:2022年04月12日 18:16:34 作者:Ezekiel Mok
这篇文章主要介绍了Python使用matplotlib.pyplot as plt绘图图层优先级问题.文章围绕主题展开详细内容需要的小伙伴可以参考一下
前言:
在最近做多智能车的控制时,绘制障碍物的时候发现障碍物的图层被路面图层所覆盖,一时不知道怎么解决,其实在用matplotlib.pyplot 绘图的时候可以使用参数zorder设置优先级进行调节,zorder整数越大,显示时越靠上。
调整前:
ax.hlines(y=30, xmin=-50, xmax=200, color='gray', linewidth=50) ax.hlines(y=0, xmin=-50, xmax=200, color='gray', linewidth=50) ax.hlines(y=-30, xmin=-50, xmax=200, color='gray', linewidth=50) obstacle = plt.Circle((120.0, -5.0), 5.0, color='red', fill=True, linewidth=1) obstacle1 = plt.Circle((60.0, 27.0), 5.0, color='red', fill=True, linewidth=1) obstacle2 = plt.Circle((60.0, -29.0), 5.0, color='red', fill=True, linewidth=1)

调整后:
ax.hlines(y=30, xmin=-50, xmax=200, color='gray', linewidth=50, zorder=1) ax.hlines(y=0, xmin=-50, xmax=200, color='gray', linewidth=50, zorder=1) ax.hlines(y=-30, xmin=-50, xmax=200, color='gray', linewidth=50, zorder=1) obstacle = plt.Circle((120.0, -5.0), 5.0, color='red', fill=True, linewidth=1, zorder=2) obstacle1 = plt.Circle((60.0, 27.0), 5.0, color='red', fill=True, linewidth=1, zorder=2) obstacle2 = plt.Circle((60.0, -29.0), 5.0, color='red', fill=True, linewidth=1, zorder=2)

到此这篇关于Python使用matplotlib.pyplot as plt绘图图层优先级问题的文章就介绍到这了,更多相关python图层优先级内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!
相关文章
利用Python-iGraph如何绘制贴吧/微博的好友关系图详解
这篇文章主要给大家介绍了关于利用Python-iGraph如何绘制贴吧/微博好友关系图的相关资料,文中显示介绍了在windows系统下安装python-igraph的步骤,然后通过示例代码演示了绘制好友关系图的方法,需要的朋友可以参考下。2017-11-11


最新评论