File: legend_demo2.py

package info (click to toggle)
matplotlib 1.1.1~rc2-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 66,076 kB
  • sloc: python: 90,600; cpp: 69,891; objc: 5,231; ansic: 1,723; makefile: 171; sh: 7
file content (24 lines) | stat: -rw-r--r-- 628 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/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 lines
l1,    = 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')
#axis([0,2,-1,1])
show()