Python: x-y-plot with matplotlib

Posted by kame on Stack Overflow See other posts from Stack Overflow or by kame
Published on 2010-04-23T14:31:53Z Indexed on 2010/04/24 7:43 UTC
Read the original article Hit count: 458

Filed under:
|
|
|
|

I want to plot some data. The first column contains the x-data. But matplotlib doesnt plot this. Where is my mistake?

#fresnel formula

import numpy as np
from numpy import cos
from scipy import *
from pylab import plot, show, ylim, yticks
from matplotlib import *
from pprint import pprint

n1 = 1.0
n2 = 1.5

#alpha, beta, intensity
data = [
    [10,    22,     4.3],
    [20,    42,     4.2],
    [30,    62,     3.6],
    [40,    83,     1.3],
    [45,    102,    2.8],
    [50,    123,    3.0],
    [60,    143,    3.2],
    [70,    163,    3.8],
    ]

for i in range(len(data)):
    rhotang1 = (n1 * cos(data[i][0]) - n2 * cos(data[i][1]))
    rhotang2 = (n1 * cos(data[i][0]) + n2 * cos(data[i][1]))
    rhotang = rhotang1 / rhotang2
    data[i].append(rhotang) #append 4th value

pprint(data)
x = data[:][0]
y1 = data[:][2]
y3 = data[:][3]
plot(x, y1, x, y3)
show()

EDIT: http://paste.pocoo.org/show/205534/ But it doesnt work.

© Stack Overflow or respective owner

Related posts about python

Related posts about beginner