在最近做多智能车的控制时,绘制障碍物的时候发现障碍物的图层被路面图层所覆盖,一时不知道怎么解决,其实在用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)