我希望 Mathematica 从原点到上面的所有点画一条线.换句话说,从原点 (0,0) 到上述集合中的所有单个点绘制向量.有没有办法做到这一点?到目前为止,我已经尝试了 Filling 选项、PlotPoints 和 VectorPlot,但它们似乎无法做我想做的事. 解决方案 先简单后难:Graphics[{Arrow[{{0, 0}, #}] &/@列表1}]Graphics[{Arrow[{{0, 0}, #}] &/@ list1},轴 ->真的]Needs["PlotLegends`"];list1 = {{3, 1}, {1, 3}, {-1, 2}, {-1, -1}, {1, -2}};k = ColorData[22, "ColorList"][[;;长度@list1]];图形行[{图形[Riffle[k, Arrow[{{0, 0}, #}] &/@#],轴 ->真的],Graphics@Legend[Table[{k[[i]], #[[i]]}, {i, Length@#}]]}] &@list1Needs["PlotLegends`"];list1 = {{3, 1}, {1, 3}, {-1, 2}, {-1, -1}, {1, -2}};k = ColorData[22, "ColorList"][[;;长度@list1]];ls = 序列[粗, 线[{{0, 0}, {1, 0}}]];图形行[{图形[Riffle[k, Arrow[{{0, 0}, #}] &/@#],轴 ->真的],图形@Legend[MapThread[{Graphics[{#1, ls}], #2} &, {k, #}]]}] &@list1Needs["PlotLegends`"];list1 = {{3, 1}, {1, 3}, {-1, 2}, {-1, -1}, {1, -2}};pr = {Min@#, Max@#} &//@转置@list1;k = ColorData[22, "ColorList"][[;;长度@list1]];图形行[{图形[r = Riffle[k, {Thick,Arrow[{{0, 0}, #}]} &/@#],轴 ->真的],图形@图例[地图线程[{图形[#1,轴 ->是的,滴答声 ->无,PlotRange ->pr],Text@Style[#2, 20]} &,{分区[r, 2], #}]]}] &@list1你也可以调整 ListVectorPlot,虽然我不明白你为什么要这样做,因为它不打算这样使用:list1 = {{3, 1}, {1, 3}, {-1, 2}, {-1, -1}, {1, -2}};数据 = 表[{i/2, -i/Norm[i]}, {i, list1}];ListVectorPlot[data, VectorPoints ->全部,VectorScale ->{1, 1, 范数[{#1, #2}] &},矢量样式 ->{箭头[{-.05, 0}]}]I have a set of points given 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 the points above. In other words draw vectors from the origin (0,0) to all the individual points in the above set. Is there a way to do this? So far I've tried the Filling option, PlotPoints and VectorPlot but they don't seem to be able to do what I want. 解决方案 Starting easy, and then increasing difficulty:Graphics[{Arrow[{{0, 0}, #}] & /@ list1}]Graphics[{Arrow[{{0, 0}, #}] & /@ list1}, Axes -> True]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@#}]]}] &@list1Needs["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, #}]]}] &@list1Needs["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], #}]]}] &@list1You could also tweak ListVectorPlot, although I don't see why you should do it, as it is not intended to use like this: 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}]}] 这篇关于有没有办法在 mathematica 中绘制一组具有相同原点的线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
07-25 20:03