 # Arrows acting funny

I wanted to make a function to take another function that takes a 2d-vector
and returns a 2d-vector, x and y boundaries, and a resolution, and plot the
slope field. However all I get is a blank plot over a small range and some
vertical and horizontal lines. This is my code, if you know differential
equations with the function I'm using you should see a saddle at the origin
and a center at 1,1.

import matplotlib.pyplot as plt

def plot_system(function, xmin, xmax, ymin, ymax, resolution):
xnow = xmin
i = 0
while xnow < xmax:
ynow = ymin
while ynow < ymax:
direction = function([xnow, ynow])
if direction**2 + direction**2 != 0:
scale = resolution / (direction**2 + direction**2)**.5
print repr(direction * scale) + ", " + repr(direction * scale)
plt.arrow(xnow, ynow, direction * scale, direction * scale)
ynow = ynow + resolution
xnow = xnow + resolution
print "plotting"
plt.show()

if __name__ == "__main__":
def function(y):
return [y - y*y, y*y - y]

plot_system(function, -10, 10, -10, 10, 1)

···

--
View this message in context: http://www.nabble.com/Arrows-acting-funny-tp20713470p20713470.html
Sent from the matplotlib - users mailing list archive at Nabble.com.