Is there a way to draw a set of lines in math with the same starting point?

I have a set of points defined by this list:

list1 = {{3, 1}, {1, 3}, {-1, 2}, {-1, -1}, {1, -2}};

I would like Mathematica to draw a line from the origin to all of the points above. In other words, draw vectors from the origin (0,0) to all the individual points in the set above. Is there any way to do this? So far I have tried the Filling , PlotPoints and VectorPlot , but they don't seem to be able to do what I want.

+4
source share
2 answers

Starting is simple and then increasing complexity:

 Graphics[{Arrow[{{0, 0}, #}] & /@ list1}] 

enter image description here

 Graphics[{Arrow[{{0, 0}, #}] & /@ list1}, Axes -> True] 

enter image description here

 Needs["PlotLegends`"]; list1 = {{3, 1}, {1, 3}, {-1, 2}, {-1, -1}, {1, -2}}; k = ColorData[22, "ColorList"][[;; Length@list1 ]]; GraphicsRow[{ Graphics[Riffle[k, Arrow[{{0, 0}, #}] & /@ #], Axes -> True], Graphics@Legend [Table[{k[[i]], #[[i]]}, {i, Length@ #}]]}] &@list1 

enter image description here

 Needs["PlotLegends`"]; list1 = {{3, 1}, {1, 3}, {-1, 2}, {-1, -1}, {1, -2}}; k = ColorData[22, "ColorList"][[;; Length@list1 ]]; ls = Sequence[Thick, Line[{{0, 0}, {1, 0}}]]; GraphicsRow[{ Graphics[Riffle[k, Arrow[{{0, 0}, #}] & /@ #], Axes -> True], Graphics@Legend [MapThread[{Graphics[{#1, ls}], #2} &, {k, #}]]}] &@list1 

enter image description here

 Needs["PlotLegends`"]; list1 = {{3, 1}, {1, 3}, {-1, 2}, {-1, -1}, {1, -2}}; pr = { Min@ #, Max@ #} & /@ Transpose@list1 ; k = ColorData[22, "ColorList"][[;; Length@list1 ]]; GraphicsRow[{ Graphics[r = Riffle[k, {Thick,Arrow[{{0, 0}, #}]} & /@ #], Axes -> True], Graphics@ Legend[MapThread[ {Graphics[#1, Axes -> True, Ticks -> None, PlotRange -> pr], Text@Style [#2, 20]} &, {Partition[r, 2], #}]]}] &@list1 

enter image description here

You can also configure ListVectorPlot , although I do not understand why you should do this, since it is not intended to be used as follows:

 list1 = {{3, 1}, {1, 3}, {-1, 2}, {-1, -1}, {1, -2}}; data = Table[{i/2, -i/Norm[i]}, {i, list1}]; ListVectorPlot[data, VectorPoints -> All, VectorScale -> {1, 1, Norm[{#1, #2}] &}, VectorStyle -> {Arrowheads[{-.05, 0}]}] 

enter image description here

+12
source
 Graphics[ { Line[{{0, 0}, #}] & /@ list1 } ] 

enter image description here

where /@ is the abbreviation for infix for the Map function.

I wonder why you tried Filling , Plotpoints and VectorPlot . I must assume that you have not read the documentation at all, because even a superficial reading will tell you that these commands and parameters have nothing to do with the functionality you are looking for.

+6
source

Source: https://habr.com/ru/post/904871/


All Articles