2011-06-30 31 views
1

几天前我问了一个类似的问题,但是它的风格略有不同;当然更具体。通过php中的脚本生成gnuplot eps文件

我有一个php文件,动态地创建一个gnuplot脚本,然后使用另一个php文件事先创建的4个文本文件(每行1个图)运行该脚本。

问题是graph.eps文件生成空白,我无法弄清楚。我有一种感觉,它与文本文件所在目录有关。

这是我生成并运行的文件。

set terminal postscript enhanced color 
set size ratio 0.7058 
set output '/srv/../A.2.5.1a.eps' 
set grid 

set key font "Arial,10" 
set key center bot 
set key out vertical 
set key horizontal center 
set key box 

set style line 1 linetype 1 linecolor rgb "red" linewidth 2.000 pointtype 6 pointsize  default 
set style line 3 linetype 1 linecolor rgb "#DAA520" linewidth 2.000 pointtype 6 pointsize default 
set style line 4 linetype 1 linecolor rgb "#006400" linewidth 2.000 pointtype 6 pointsize default 
set style line 6 linetype 1 linecolor rgb "blue" linewidth 2.000 pointtype 6 pointsize default 

set multiplot 
set palette model RGB functions 0.8+gray/3, 0.8+gray/3, 0.8+gray/3 
set pm3d map 
set isosample 100,100 

unset colorbox 
unset border 
unset xtics 
unset ytics 
set nokey 
set nolabel 
set size 1.025,1.2 
set origin -0.021,-0.06 

splot y t ' ' 

set title "SECTION A.2.5.1a TEST RESULTS" 
set key box 
set key horizontal center bot 
set y2tics 0 , 200 
set ytics nomirror 
set xtics nomirror 

set border 
set xtics 250 
set xtics font "Arial,8" 
set ytics 1750 
set size 1,1 
set xtics out offset -1,-0.5 
set xtics rotate by 45 

unset origin 
unset x2tics 

set xlabel "Loop Length, 26AWG(kft)" 
set ylabel "Downstream Data Rate (kbps)" 
set y2label "Upstream Data Rate (kbps)" 
set xrange [ 250 : 5500 ] noreverse nowriteback 
set yrange [ 0 : 14000 ] noreverse nowriteback 
set y2range[ 0 : 1400 ] noreverse nowriteback 
set bmargin 7 

plot "DSE_A.2.5.1a.txt" ls 4 title 'Expected Downstream Rate' with linespoints,  \ 
"DS_A.2.5.1a.txt" ls 1 title 'Measured Downstream Rate' with linespoints, \ 
\ 
"USE_A.2.5.1a.txt" axes x1y2 ls 6 title 'Expected Upstream Rate' with linespoints, \ 
"US_A.2.5.1a.txt" axes x1y2 ls 3 title 'Measured Upstream Rate' with linespoints 

unset multiplot 

一旦被创建,我使用:

exec("{$pathName} gnuplot {$File}"); 

的$路径名的CWD的文件和文件$解释变量本身。

我试过使用plot $ pathname/DS_A.2.5.1a.txt等,但这也不起作用。

感谢您的时间,我对这篇冗长的文章表示歉意。我改变了设定的输出路径,因为它很长,并且包含相对私人的信息。

谢谢,我期待着所有的回应!

编辑:我刚刚读了http://linux.byexamples.com/archives/487/plot-your-graphs-with-command-line-gnuplot/,我认为这可能不是chmod-ing,而其他命令可能是一个问题,但是当我尝试它仍然不起作用时。

因为它在服务器上远程运行,所以我没有收到我手动运行gnuplot时所做的错误消息。

+0

如果这个空白输出仅与EPS端和未发生对于x11或pdfcairo终端,则发现问题。如果不是这种情况,请尝试通过调用它来代替使用数据文件作为输入到图的使用函数,如x或2 * x。如果我用伪函数而不是数据文件运行脚本,我不会得到空白输出。 – Woltan

+0

我可以自己调试,但我没有在运行此脚本的服务器上写入权限,所以我实际上无法手动尝试。该脚本通过管理员帐户在服务器上运行。 – Joshua

回答

1

显示执行的命令可能很有意义。相反的:

exec("{$pathName} gnuplot {$File}"); 

尝试

$command_to_execute = "$pathName gnuplot $File"; 
echo $command_to_execute . "\n"; 
exec($command_to_execute); 

看来,你对gnuplot路径无效。您可能需要删除的空间,就像这样:

$command_to_execute = "{$pathName}gnuplot {$File}"; 

,你可能需要添加一个斜杠,像这样:

$command_to_execute = "{$pathName}/gnuplot {$File}"; 
+0

我会尝试,但我已切换到 exec(“gnuplot {$ pathName}/{$ File}”); 这并不工作,要么 – Joshua

+0

只是尝试过你的建议,不幸的是骰子:( – Joshua

+0

你应该指定gnuplot的完整路径,并确保web服务器用户有权执行它。 –