Subscribe to DSC Newsletter

This is a follow up to our article on Structuredness coefficient to find patterns and associations, featuring an image (animated gif) with rotating dots that simulate waves. I went one step further here, to create a new data video, where rotating points (by accident) simulate sensual waves, not unlike belly dancing. You'll understand what I mean when you see the video.

Here I provide the source code and methodology to create this video. Click here to view the video, including a link to the YouTube version.

1. Algorithm to create the data

The video features a rectangle with 20 x 20 moving points, initially evenly spaced, each point rotating around an invisible circle.

Here's the algorithm:

The parameter c governs the speed of the rotations, and r the radius of the underlying circles.


  print OUT "iter\tx\ty\tz\n";

  for ($iter=0; $iter<1000; $iter++) {

    for ($k=0; $k<20; $k++) {
      for ($l=0; $l<20; $l++) {



        print OUT "$iter\t$x\t$y\t$color\n";



2. Source code to produce the video

Here's the R source code. The input data is the file movie.txt produced in the previous step. Note that $iter represents the frame number in the video. Here I used 1,000 frames and the video lasts about 60 seconds.



  for (n in 0:999) {

    x<-vv$x[iter == n];
    y<-vv$y[iter == n];
    z<-vv$z[iter == n];
    Sys.sleep(0.01); # sleep 0.05 second between each iteration

3. Saving and exporting the video

I used a screen-cast software (Active Presenter, open source) to do the job. It's the same as as screen shot software or print screen, except that instead of saving a static image, it saves streaming data. Click here for details.

Related articles

Views: 4326


You need to be a member of AnalyticBridge to add comments!

Join AnalyticBridge

Comment by Vincent Granville on July 17, 2013 at 6:21pm
When the oscillations are flat before it becomes high amplitude waves (that is, at the end of the belly dancing episode in the middle of the video), it reminds me the oscillations of the famous, old Tacoma narrow bridge just seconds before it collapsed due to harmonic oscillations caused by wind.

On Data Science Central

© 2021   TechTarget, Inc.   Powered by

Badges  |  Report an Issue  |  Privacy Policy  |  Terms of Service