I'm trying to plot a large array of vectors using pyplot. Right now I've got
import matplotlib.pyplot as plt
import numpy as np
import operator
t = np.arange(0, np.pi, .01)
def pos1(t):
x1 = .72 * np.cos(13*t)
y1 = .72 * np.sin(13*t)
return x1, y1
def pos2(t):
x2 = np.cos(8*t)
y2 = np.sin(8*t)
return x2, y2
def vec(t):
x1 = pos1(t)[0]
x2 = pos2(t)[0]
y1 = pos1(t)[1]
y2 = pos2(t)[1]
x = np.subtract(x1, x2)
y = np.subtract(y1, y2)
return x, y
X = pos2(t)[0]
Y = pos2(t)[1]
U = vec(t)[0]
V = vec(t)[1]
plot1 = plt.figure()
plt.quiver(X, Y, U, V, headlength=4)
plt.show(plot1)
Where pos1(t), pos2(t) and vec(t) are functions that return a tuple of the form ([a,...,z],[a1,...,z1]).
This plot gives me something close to what I want, but the vector lengths are all wrong. the two functions, pos1(t),pos2(t) return a tuple of the point on a particular curve, and the vec(t) function is their difference, leading to a vector from a point on the first curve to a point on the second. My plot has the correct direction, but not magnitude.



pos2andvecare. Also, please tell us what your expected output is. Lastly, is there a typo in your snippet? Is it supposed to beX = pos1(t)?pos1is currently not referenced anywhere in your snippet.