39 import matplotlib.pyplot
as plt
40 from pylab
import meshgrid, arange, quiver, quiverkey, sqrt
43 def makeVectorField(f, xmin, xmax, ymin, ymax, step):
44 X, Y = meshgrid(arange(xmin, xmax, step), arange(ymin, ymax, step))
45 U, V = zip(*map(
lambda xx: f(*xx), zip(X, Y)))
46 Q = quiver(X, Y, U, V, units=
'width')
47 quiverkey(Q, 0, 0, 4,
'', coordinates=
'figure', labelpos=
'W')
50 ax = fig.gca(aspect=
'equal')
51 x = np.loadtxt(
"vfrrt-nonconservative.path")
52 makeVectorField(
lambda x, y: (y / sqrt(x * x + y * y + 1e-6), -x / sqrt(x * x + y * y + 1e-6)),
54 ax.plot(x[:, 0], x[:, 1])