2012-07-25 22 views
3

調用gnuplot的腳本有gnu.gp文件:我如何從perl的

# grphist.conf 
set terminal canvas 
#Terminal type set to 'canvas' 
#Options are ' solid butt size 600,400 fsize 10 lw 1 fontscale 1 standalone' 
set output 'output.html' 

set grid 
set xtic rotate by 90 
set style data histograms 
set style fill solid 1.00 border -1 
#$ cat grphist.conf | gnuplot 
plot "c_time" using 2:xtic(1) title "time to number of UIDs" 

但是,我必須這樣用perl腳本集成。

回答

9

您可以打開一個管道GNUPLOT:

use autodie qw(:all); 
open my $GP, '|-', 'gnuplot'; 

print {$GP} <<'__GNUPLOT__'; 
    set xrange [-5:5]; 
    plot sin(x); 
__GNUPLOT__ 

close $GP; 

或者,您可以在CPAN上找到Chart::Gnuplot

+0

對我很好用對我有幫助 – 2012-07-25 09:30:06

+0

當我檢查你的代碼時,在腳本/ temp.pl的EOF之前的任何地方出現'Can not find string terminator __GNUPLOT__「錯誤。有什麼想法嗎?謝謝。 – SSilk 2016-11-28 21:40:33

+0

@SSilk:奇怪。我可以清楚地看到第7行的__GNUPLOT__。 – choroba 2016-11-28 21:42:56