网络编程
位置:首页>> 网络编程>> Python编程>> Python使用matplotlib.pyplot as plt绘图图层优先级问题

Python使用matplotlib.pyplot as plt绘图图层优先级问题

作者:Ezekiel?Mok  发布时间:2022-06-10 18:00:37 

标签: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)

Python使用matplotlib.pyplot as plt绘图图层优先级问题

调整后: 

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绘图图层优先级问题

来源:https://blog.csdn.net/Ezekiel_Mok/article/details/124108306

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com