通过php中的脚本生成gnuplot eps文件

发布于 2024-11-17 21:18:16 字数 2591 浏览 3 评论 0原文

几天前我问过类似的问题,但这次的味道略有不同;当然更具体。

我有一个 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}");

$pathName 是文件的 CWD,$File 变量会自行解释。

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

感谢您抽出时间,对于冗长的帖子我深表歉意。我更改了设置的输出路径,因为它很长并且包含相对私密的信息。

谢谢,我期待所有的回复!

编辑:我刚刚阅读 http://linux .byexamples.com/archives/487/plot-your-graphs-with-command-line-gnuplot/ 我认为这可能不是 chmod-ing 并且其他命令可能是一个问题,但是当我尝试了一下还是不行。

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

I asked a similar question a few days ago, but this is of a slightly different flavor; certainly more specific.

I have a php file that creates a gnuplot script dynamically, and then runs that script using 4 text files (1 per line of the plot) created beforehand with another php file.

The problem is that the graph.eps files are generated blank and I cannot figure it out. I have a feeling that it has something to do with the directory the text files are in.

This is the file I generate and then run.

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

Once this is created, I use:

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

The $pathName is the CWD for the file and the $File variable explains itself.

I've tried using plot $pathname/DS_A.2.5.1a.txt, etc but that doesn't work either.

Thanks for your time and I apologize about the lengthy post. I changed the set output path because it was very long and contains relatively private information.

Thanks and I look forward to all responses!

Edit: I just read http://linux.byexamples.com/archives/487/plot-your-graphs-with-command-line-gnuplot/ and I think that maybe not chmod-ing and that other command might be a problem, but when I try that it still doesn't work.

Since it's being run remotely on a server I do not get the error messages that I do when I manually run gnuplot.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不羁少年 2024-11-24 21:18:16

显示执行的命令可能会有所帮助。而不是:

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

try

$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}";

It may be instructive to display the executed command. Instead of:

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

try

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

It appears that your path to gnuplot is invalid. You may need to remove the space, like this:

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

and you may need to add a slash, like this:

$command_to_execute = "{$pathName}/gnuplot {$File}";
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文