legend_demo2.py

来自「非原创。很好的python例子」· Python 代码 · 共 26 行

PY
26
字号
#!/usr/bin/env python## Make a legend for specific lines.  from pylab import *t1 = arange(0.0, 2.0, 0.1)t2 = arange(0.0, 2.0, 0.01)# note that plot returns a list of lines.  The "l1, = plot" usage# extracts the first element of the list inot l1 using tuple# unpacking.  So l1 is a Line2D instance, not a sequence of linesl1,    = plot(t2, exp(-t2))l2, l3 = plot(t2, sin(2*pi*t2), '--go', t1, log(1+t1), '.')l4,    = plot(t2, exp(-t2)*sin(2*pi*t2), 'rs-.')legend( (l2, l4), ('oscillatory', 'damped'), 'upper right', shadow=True)xlabel('time')ylabel('volts')title('Damped oscillation')#savefig('legend_demo2')#axis([0,2,-1,1])show()

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?