Calling Gnuplot from Perl
In my previous post I discussed how to call Gnuplot from C and Python language. If you are using Perl, then, here is the script:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | #!/usr/bin/perl # Generate postscript and png plot with GNUplot from Perl # Author: Ioan Vancea # Usage: Give "data file" as an argument for script use strict; use warnings; my $file = ARGV[0]; # POSTSCRIPT open (GNUPLOT, "|gnuplot"); print GNUPLOT <<EOPLOT; set term post color "Courier" 12 set output "$file.ps" set size 1 ,1 set nokey set data style line set xlabel "frequency" font "Courier,14" set title "Fast Fourier Transform" font "Courier,14" set grid xtics ytics set xtics 100 plot "$file" using 1:2 w lines 1 EOPLOT close(GNUPLOT); # PNG open (GNUPLOT, "|gnuplot"); print GNUPLOT <<EOPLOT; set term png small xFFFFFF set output "$file.png" set size 1 ,1 set nokey set data style line set xlabel "frequency" font "VeraMono,10" set title "Fast Fourier Transform" font "VeraMono,10" set grid xtics ytics set xtics 100 plot "$file" using 1:2 w lines 1 EOPLOT close(GNUPLOT); |
If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.














You, probably, meant $ARGV[0], instead of ARGV[0]. But it is handy little script, thanks!