图层按照与绘图函数相对应的调用顺序从下到上堆叠。
import matplotlib.pyplot as plt
lineWidth = 30
plt.figure()
plt.subplot(2, 1, 1) # upper plot
plt.plot([-1, 1], [-1, 1], lw=5*lineWidth, c='b') # bottom blue
plt.plot([-1, 1], [-1, 1], lw=3*lineWidth, c='r') # middle red
plt.plot([-1, 1], [-1, 1], lw=lineWidth, c='g') # top green
plt.subplot(2, 1, 2) # lower plot
plt.plot([-1, 1], [-1, 1], lw=5*lineWidth, c='g') # bottom green
plt.plot([-1, 1], [-1, 1], lw=3*lineWidth, c='r') # middle red
plt.plot([-1, 1], [-1, 1], lw=lineWidth, c='b') # top blue
plt.show()
它清楚地从下面的是,图是根据底部第一,顶最后规则布置图中出现。
我看到zorder与它有关。但是,我仍然无法按照自己的意愿开展工作。如果我将蓝色,红色和绿色的zorder分别设置为0,1和2,则红色线是最上面的那条线。为什么?? – Phys251