开发者

Animate List on a graph in Mathematica?

开发者 https://www.devze.com 2023-03-22 14:59 出处:网络
I have a matrix of coordinates (X,Y), and I want to animate them by plotting point by point and connect the points. I tried \"ListAnimate\" b开发者_JAVA百科ut it only animates the values of each coord

I have a matrix of coordinates (X,Y), and I want to animate them by plotting point by point and connect the points. I tried "ListAnimate" b开发者_JAVA百科ut it only animates the values of each coordinate..

Here is what the sample look like:

{{1,1},
{1,2},
{5,4},...}


May be

max = 10;
coords = Table[{i, RandomReal[]}, {i, max}];

Animate[ListPlot[coords[[1 ;; n]], PlotMarkers -> {Automatic, Small}, 
  Joined -> True, PlotRange -> {{0, max}, {0, 1}}], {n, 1, max, 1}]


Just an illustrative answer. All the following also do the same thing:


max = 10;
coords = Table[{i, RandomReal[]}, {i, max}];
p = PlotRange -> {{0, max}, {0, 1}};


Animate[
 ListLinePlot[coords[[1 ;; n]],   Mesh -> All, p],
{n, Range@max}]

Animate[
  Graphics[{Point@#, Line@#}, p, Axes -> True] &@coords[[1 ;; n]], 
{n, Range@max}]

Animate[
 Graphics[{ Red,   Point[#], 
            Black, BSplineCurve[#, SplineDegree -> 1]}, p] &@coords[[1 ;; n]],
{n, Range@max}]
0

精彩评论

暂无评论...
验证码 换一张
取 消