【问题标题】:About my versions of gnuplot and my terminals关于我的 gnuplot 版本和我的终端
【发布时间】:2019-09-26 06:44:39
【问题描述】:

我想制作一个 gif 文件,对名称为 1.dat、2.dat 的文件进行迭代...我已尝试使用此代码:

!/usr/bin/gnuplot

unset key 

plot "dades.dat" using 1:2                      #

h=GPVAL_DATA_Y_MIN #1.69794089321728966E-045    #

plot "dades.dat" using 1:3                      #------>Dummy plots per tal de guardar en 
variables

d=GPVAL_DATA_Y_MIN #7.12168589558569665E-046    #          els valors ses amplades de ses malles

plot "dades.dat" using 1:4                      #

c=GPVAL_DATA_Y_MIN                              #

plot "dades.dat" using 1:5                      #

lam=GPVAL_DATA_Y_MIN                            #

plot "dades.dat" using 1:6                      #

n=GPVAL_DATA_Y_MIN                              #


i=0
set terminal gif      
unset key                        
set output "film.gif"
set title "V(x)"
set xlabel "x(m)"
set ylabel "V(V)"

i=i+1

if( i < n ) reread;

但是当我使用终端执行时,我的变量不会改变,也不会停止循环。

后来我用其他形式来做循环,比如:

do for [i=0:n] {
infile(i) = sprintf("%d.dat",i)
print i
plot infile(i) w l  using 1:2
}

但是,当我执行时,终端会显示下一个错误:

do for [i=0:n] {
               ^
"./film.gnuplot", line 22: invalid complex constant

非常奇怪,因为我已经安装了 4.6 版本的 gnuplot。然后我试着把终端 gnuplot ./film.gnuplot 放进去然后给我看:

set terminal gif      
             ^
"film.gnuplot", line 15: unknown or ambiguous terminal type; type just 'set terminal' for a list

最后,我执行了 gnuplot,我编写了帮助终端命令并显示我已经安装了所有这些终端:

   canvas            cgm               context           corel
    dumb              dxf               eepic             emf
    emtex             epslatex          fig               gpic
    hp2623a           hp2648            hpgl              imagen
    latex             mf                mif               mp
    pcl5              pop               postscript        pslatex
    pstex             pstricks          push              qms
    regis             svg               tek40xx           tek410x
    texdraw           tgif              tkcanvas          tpic
    vttek             xterm

非常奇怪,因为我总是使用 png 终端并且从不显示错误,但是当我使用 gnuplot 执行时,它会显示错误。

我正在使用 Ubuntu

【问题讨论】:

  • 如果你运行gnuplot --version,输出是什么?奇怪的是,正如您所说,您通常使用 png 终端但它没有被列为已安装。您也可以在 gnuplot 中运行print GPVAL_TERMINALS 来检查安装了哪些终端。
  • 感谢回答。如果我运行 gnuplot --version,它显示我有 gnuplot 4.6 patchlevel 5
  • 奇怪。您使用的是哪个操作系统?您是自己编译/安装 gnuplot 还是使用软件包?我看到的一件事是您使用i 作为循环计数器和变量,而gnuplot 抱怨invalid complex constant,可能是因为它试图使用i 来表示-1 的平方根。尝试使用不同的变量名(例如ii)。 i 表示复杂常量的问题在很多语言中都是通用的,所以不要将ij 用作变量是一个好习惯。
  • 我使用的是 Ubuntu,我手动安装了 gnuplot(直接从 gnuplot 网站下载,从终端开始安装)。关于变量的名称,我更改了它,但错误消息仍然显示。
  • @andyras Gnuplot 使用符号 {0,1} 表示虚数常数 i。由于 4.4 版不知道 do for 循环,因此它需要在左括号后有一个复数。

标签: ubuntu plot gnuplot gif


【解决方案1】:

骨头奥斯卡,

对我来说有效的方法如下。它不是很优雅..我有一个第一个脚本'animar.gnu',我在其中加载了gif终端,然后是第二个脚本来绘制循环'plot.gnu'。在第一个:

    set terminal gif animate
    set output 'peli.gif'
    ii=1
    load 'plot.gnu'
    set terminal wxt
    set output

第二个如下

    infile(ii) = sprintf("%d.dat",ii)
    plot infile(ii) u 1:2
    ii = 1 + ii
    if (ii<4) reread

这将从 ii=1 运行到 ii=4,并绘制第一列与第二列。

如果问题是你没有 gif 终端...那么这是以前的问题。

我曾经在一个类似的页面中找到了解决方案:http://www.gnuplot.info/announce_4.6.3.txt

【讨论】:

  • 感谢回答。我试过像你的例子那样做,但不要让我重新调整终端。我尝试安装它,但我安装到了 gnuplot 的 previuos 版本。谢谢。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-06-21
  • 1970-01-01
  • 1970-01-01
  • 2015-06-08
相关资源
最近更新 更多