x = [ 5, 6, 7, 8 ]
y = [ 10, 55, 22, 4 ]
plot(x, y)
[<matplotlib.lines.Line2D at 0x105f94d50>]
%%file numbers.dat
3,20
5,55
7,22
8,50
9,20
10,30
15,45
Overwriting numbers.dat
%%file numbers2.dat
1,2
3,4
5,6
7,8
Overwriting numbers2.dat
import csv
fp = open('numbers.dat')
r = csv.reader(fp)
x2 = []
y2 = []
for a, b in r:
a = float(a)
b = float(b)
x2.append(a)
y2.append(b)
fp = open('numbers2.dat')
r = csv.reader(fp)
x3 = []
y3 = []
for a, b in r:
a = float(a)
b = float(b)
x3.append(a)
y3.append(b)
plot(x2, y2)
plot(x3, y3)
[<matplotlib.lines.Line2D at 0x10690de90>]
num1 = numpy.loadtxt?
%%file numbers3.dat
10,20,30
30,40,50
50,60,50
70,80,70
Writing numbers3.dat
num1 = numpy.loadtxt('numbers.dat', delimiter=',')
num2 = numpy.loadtxt('numbers2.dat', delimiter=',')
num3 = numpy.loadtxt('numbers3.dat', delimiter=',')
num4 = num3*2
plot(num1[:,0], num1[:,1], label='num1')
plot(num2[:,0], num2[:,1], label='num2')
plot(num3[:,0], num3[:,2], label='num3')
plot(num4[:,0], num4[:,2], label='num4')
legend()
<matplotlib.legend.Legend at 0x106f39710>