fra*_*lin 4 wolfram-mathematica
我有一个由这个列表给出的一组点:
list1 = {{3, 1}, {1, 3}, {-1, 2}, {-1, -1}, {1, -2}};
我希望Mathematica从原点到上面的所有点绘制一条线.换句话说,从原点(0,0)到上述集合中的所有单个点绘制矢量.有没有办法做到这一点?到目前为止,我已经试过了Filling
选项,PlotPoints
以及VectorPlot
,但他们似乎并不能够做我想做的.
Dr.*_*ius 12
开始容易,然后增加难度:
Graphics[{Arrow[{{0, 0}, #}] & /@ list1}]
Run Code Online (Sandbox Code Playgroud)
Graphics[{Arrow[{{0, 0}, #}] & /@ list1}, Axes -> True]
Run Code Online (Sandbox Code Playgroud)
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
Run Code Online (Sandbox Code Playgroud)
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
Run Code Online (Sandbox Code Playgroud)
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
Run Code Online (Sandbox Code Playgroud)
你也可以调整ListVectorPlot
,虽然我不明白为什么你应该这样做,因为它不打算像这样使用:
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}]}]
Run Code Online (Sandbox Code Playgroud)
Graphics[
{
Line[{{0, 0}, #}] & /@ list1
}
]
Run Code Online (Sandbox Code Playgroud)
其中/@
是函数的简写中缀表示法Map
.
我想知道你为什么试过Filling
,Plotpoints
而且VectorPlot
.我必须假设你根本没有阅读过这些文档,因为即使是一个肤浅的阅读也会告诉你这些命令和选项与你正在寻找的功能无关.