In [ ]:
import k3d
from math import sin, cos, pi

width = height = 50
model_matrix = [
    7.0,  5.0, -5.0, 0.0,
    0.0,  7.0,  7.0, 5.0,
    7.0, -5.0,  5.0, 0.0,
    0.0,  0.0,  0.0, 1.0
]

def f(x, y):
    return sin(float(x) / width * pi * 2.0), cos(float(y) / height * pi * 2.0)

colors = (0xFF0000, 0x00FF00) * width * height
vectors = [[f(x, y) for x in range(width)] for y in range(height)]

plot = k3d.plot()
plot += k3d.vector_field(vectors, colors, model_matrix=model_matrix)
plot.display()
In [ ]:
plot.objects[0].head_size = 1.5
In [ ]:
plot.objects[0].scale = 2.0
In [ ]: