gnuplot from stdin
Since I couldn’t find this in an easy-to-use format anywhere else, here’s how you use gnuplot to plot a list of numbers sent in with stdin:
(echo plot \"-\" with lines; cat numbers.txt) | gnuplot
numbers.txt is a list of numbers, with or without terminating semicolons. Scientific notation is ok.
(30 minutes later) … and, here’s how to write a pdf graph of each text file in the current directory:
ls *.txt | perl -e 'while(<stdin>) { chomp; system "(echo set term pdf; echo set yrange [-1:1]; echo plot \\\"-\\\" with lines; cat $_ ) | gnuplot > $_.pdf"; }
(and so I don’t lose it, here’s how to generate a whole bunch of testunits:
perl -e 'for ( $i=1; $i<60; $i+=5 ) { for ( $j=$i+1; $j<150; $j*=1.5 ) { print "#X obj ".($i*40)." ".(int($j))." testunit $i-".(int($j))." $i ".(int($j))." senergy;\n"; } } ' > 1.actions/testunits.pd.txt
)
![damian [at] frey [dot] co [dot] nz](http://frey.co.nz/old/wp-content/themes/freynew/email.jpg)

March 2nd, 2010 at 12:55 pm
Very useful, thanks!