タブで区切られた値を、2個づつ取って、gnuplotで表示。

#! /usr/bin/perl
use strict;
use warnings;

my $usage = "usage: $0 data_filename";

my $datafile = shift @ARGV or die "$usage\n";
my $sleep_time = 0;

open DATA, "< $datafile" or die "can't open $datafile\n";
open GNUPLOT, "| gnuplot" or die "can't open gnuplot\n";
select( ( select(GNUPLOT), ( $| = 1 ) )[0] );

print GNUPLOT
    "set xrange [-1.5e11:1.5e11]\n",
    "set yrange [-1.5e11:1.5e11]\n",
    "set nokey\n";

while( <DATA> ){
    next if /^\#/;

    print GNUPLOT "plot '-'\n";
    while( /([\d.e+-]+)\t([\d.e+-]+)/g ){
	my ( $x, $y ) = ( $1, $2 );
	print GNUPLOT "$x\t$y\n";
    }
    print GNUPLOT "end\n";

    sleep $sleep_time;
}

sleep 10;

close GNUPLOT;
close DATA;

xrange、yrangeがやな感じ。


上の用に、原点と10個前のもいっしょに表示。

perl -ne 'next if/^#/; ($x,$y)=/(\S+)\t(\S+)/; push @tail,[$x,$y]; shift @tail if(@tail>10); print $_->[0],"\t",$_->[1],"\t" for @tail; print "0\t0\n";'

壁$_->