zorder_demo.py
来自「非原创。很好的python例子」· Python 代码 · 共 44 行
PY
44 行
#!/usr/bin/env python"""The default drawing order for axes is patches, lines, text. Thisorder is determined by the zorder attribute. The following defaultsare setArtist Z-orderPatch / PatchCollection 1Line2D / LineCollection 2Text 3You can change the order for individual artists by setting the zorder. Anyindividual plot() call can set a value for the zorder of that particular item.In the fist subplot below, the lines are drawn above the patchcollection from the scatter, which is the default.In the subplot below, the order is reversed.The second figure shows how to control the zorder of individual lines."""from pylab import *x = rand(20); y = rand(20)subplot(211)plot(x, y, 'r', lw=3)scatter(x,y,s=120)subplot(212)plot(x, y, 'r', zorder=1, lw=3)scatter(x,y,s=120, zorder=2)# A new figure, with individually ordered itemsx=frange(0,2*pi,npts=100)figure()plot(x,sin(x),linewidth=10, color='black',label='zorder=10',zorder = 10) # on topplot(x,cos(1.3*x),linewidth=10, color='red', label='zorder=1',zorder = 1) # bottomplot(x,sin(2.1*x),linewidth=10, color='green', label='zorder=3',zorder = 3)axhline(0,linewidth=10, color='blue', label='zorder=2',zorder = 2)legend()show()
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?