Lu's suggestion to use
PDL is what I would do if you want to run the visualization "live". I would go with
moritz's approach if you want to store the visualization as an animation for later playback. Here is a brief example of a 3D visualization of points using
PDL adapted from one of the examples from the docs. The
nokeeptwiddling3d() function is what allows the changes in position to be plotted while the iteration happens. If you remove that then you can step through each change in position by pressing the "q" key.
#!/usr/bin/perl -w
use strict;
use PDL;
use PDL::Graphics::TriD;
my $size = 25;
my $x = (xvals zeroes $size+1,$size+1) / $size;
my $y = (yvals zeroes $size+1,$size+1) / $size;
my $z = 0.5 + 0.5 * (sin($x*6.3) * sin($y*6.3)) ** 3; # Bumps
my $r = $x;
my $g = $y;
my $b = $z;
nokeeptwiddling3d();
for (1..50){
points3d [$x,$y,$z], [$r,$g,$b]; # Draw several colored dots
$x+=$y*$z;
}
keeptwiddling3d();
points3d [$x,$y,$z], [$r,$g,$b];