0

I even found the resultant vector and printed it's magnitude, but I can't plot it.

current results

Here is the code: Here I am finding the resultant and which is correct but my graph is incorrect. The output I am getting is at the end.

import numpy as np
a1=np.array([2,3])
a2=np.array([1,6])
import matplotlib.pyplot as plt
plt.xlim(-10,10)
plt.ylim(-10,10)
at=a1+a2
origin=np.array([0,0])
plt.quiver(*origin,at[0],at[1],scale=50)
plt.grid()
plt.ylabel('Y-axis')
plt.xlabel('X-axis')
plt.legend(['Vector Addition of two vectors'])
plt.show()
print(at)
m=np.linalg.norm(at)
print(m)

1 Answer 1

1

From the documentation at the scale_units part :

To plot vectors in the x-y plane, with u and v having the same units as x and y, use angles='xy', scale_units='xy', scale=1.

So you can change your line to this :

plt.quiver(*origin, at[0], at[1], angles='xy', scale_units='xy', scale=1)

And you'll get this result :

graph

Which is pointing at the right place i.e. (3, 9).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.