# Simple way to create 2D video given list (x, y, t)?

I have a list of (x, y, t), ( a pretty good analogy for the data is raindrops hitting a 2D plane over a period of time) and I'm trying to create a video on Mathematica so I can see visually how these points relate to each other.

Basically, the first frame should have no "raindrops" and the last frame should have the location of every raindrop that has fallen. I believe I can do this by creating a bunch of "snapshots" of the data at $t_1$, $t_1 + \Delta t$, $t_1 + 2 \Delta t$, and using an if loop through the (x, y, t) list to see which points would appear on each snapshot, then stringing a bunch of ListPlots together into a video, but this seems like a pretty inefficient way to do it.

Is there a simpler way to create a video given (x, y, t) birth sites in only a couple lines of code?

• Can't you build up a dummy minimal example? You could save a Table parametrized by $t$ and then Export it, for example. – anderstood Sep 12 '17 at 18:29
• sort the points on t if they aren't already ordered, then I see no need for an If conditional. Look up ListAnimate btw. – george2079 Sep 12 '17 at 18:32
• drops=Table[RandomReal[{0,20},3],{200}]; Export["movie.avi", Table[ListPlot[Map[Most, Select[drops, #[]<t&]], PlotRange->{{0,20},{0,20}}], {t,1,20}]]; efficiency=1/(Number of seconds spent worrying about efficiency+Number of seconds spent writing it+Number of seconds spent running it) – Bill Sep 12 '17 at 19:01
• @Bill The coefficient in front of "number of seconds spent running it once" can be very large :) – anderstood Sep 12 '17 at 19:12

You can use Select together with Animate and ListPlot to achieve what you want:

(* some random data *)
data = RandomReal[{0, 1}, {100, 3}];

Animate[
ListPlot[
Select[data, Last@# < t &][[All, {1, 2}]],
PlotRange -> {{0, 1}, {0, 1}},
Frame -> True
],
{t, 0, 1}
] pre sort the data into frames then use ListAnimate :

data = RandomReal[{0, 1}, {1000, 3}];

nframes = 50;
sorted = GatherBy[data, Round[#[], 1/(nframes - 1)] &][[All,
All, {1, 2}]];
ListAnimate[
ListPlot[#, PlotRange -> {{0, 1}, {0, 1}}] & /@
FoldList[Join, {}, sorted]]


if the data is already in time order you could also use SplitBy