2
$\begingroup$

suppose I have four vectors: v1,v2,v3,v4 at the positions (1,1),(1,-1),(-1,1),(-1,-1) respectively in position space in xy plane and the two dimensional components are (0.5,-0.5),(0.75,0.1),(0.4,0.6),(-0.5,-0.5) respectively. somebody please help how to make a vector plot with these information?

$\endgroup$
0
4
$\begingroup$
pos = Tuples[{1, -1}, {2}];
vlst = {{0.5, -0.5}, {0.75, 0.1}, {0.4, 0.6}, {-0.5, -0.5}};
colors = {Red, Green, Blue, Orange};

Graphics[MapThread[{ #, PointSize[Large], Point@#2, 
   Thick, Arrowheads[Large], Arrow[{#2 , #2 + #3}]} &, {colors, pos, vlst}], 
 Axes -> True, GridLines -> {{-1, 1}, {-1, 1}}]

enter image description here

Alternatively,

Graphics[MapThread[{ #, PointSize[Large], Point@#2, 
   Thick, Arrowheads[Large], Translate[ Arrow[{{0, 0}, #3}], #2]} &, {colors, pos, vlst}], 
  Axes -> True, GridLines -> {{-1, 1}, {-1, 1}}]

same picture

$\endgroup$
4
  • $\begingroup$ Thanks. The answer is useful $\endgroup$
    – atanu
    Oct 11 '19 at 7:40
  • $\begingroup$ I have one more query regarding this. Suppose I have thousands of vector defined in thousands points. so it is not possible to define color for individual vectors. Then how to define a color function for the all vectors? $\endgroup$
    – atanu
    Oct 11 '19 at 11:00
  • $\begingroup$ @atanu, you can use colors = ColorData["Rainbow"] /@ Rescale[Range@Length@pos]; or colors = ColorData["Rainbow"] /@ Rescale[Norm /@ (pos + vlst)]; or colors=RandomColor[Length@pos] $\endgroup$
    – kglr
    Oct 11 '19 at 14:54
  • $\begingroup$ thank you. It works fine.. $\endgroup$
    – atanu
    Oct 13 '19 at 11:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.