【发布时间】:2017-08-22 20:37:12
【问题描述】:
我在使用繁重的 gnuplot 脚本时遇到了不稳定的行为。
脚本打算绘制边界线。使用填充曲线和线条样式。还通过
显示单参数曲线族plot for [i=1:4] f(x,i) title sprintf("f(x,i) i=%d",i) w l dt 2
我在这里发了一个例子https://pbs.twimg.com/media/DHbeEgXXkAAV6aS.jpg:large
在这个情节之后,我继续介绍阿根廷。在新的代码行之后,蓝色的虚线开始出现异常。其中两个就这样消失了。
我开始调试代码并最终使用 set table 实用程序将整个绘图输出到单个文件中。
我发现 for 循环的行为异常。标题行显示循环变量 i 从开始值到结束值正确运行。然而,函数 f(x,i) 没有正确地输入正确的 i 值。
在第一次迭代中,循环运行良好,脚本绘制了 f(x,1)。在第二次迭代中,函数被正确输入并显示 f(x,2)。但此后,尽管标题字符串正确显示了 i 的变化,但该函数始终输入 i=2
结果图是
非常感谢能帮助我找到错误的提示。
我现在将添加几行代码。绘图命令
plot for [i=1:words(europa_cet)] countries u ($1+($2<36?1:0)*15):(mercator($2)) index (word(europa_cet,i)+0) w filledcurve lc rgb colorFondoCET,\
for [i=1:words(paises_wet)] countries u ($1+15+dst*word(dst_wet,i)*15):(mercator($2)) index (word(paises_wet,i)+0) w filledcurve lc rgb colorFondoWET,\
for [i=1:words(southAm)] countries u ($1+(4+dst*word(dstSouthAm,i))*15):(mercator(abs($2))) index int(word(southAm,i)) w filledcurve lc rgb colorFondoGET,\
"magallanes.dat" u (new!=2?$1+dst*15:1/0):(mercator($2)) w filledcurve lc rgb colorFondoEET,\
"no_magallanes.dat" u (new!=2?$1:1/0):(mercator($2)) w filledcurve lc rgb colorFondoEET,\
for [k=1:5:1] mercator(orto(x,real(b1)+real(k)*real(15.0))) tit sprintf("orto a %02d signo %d",k,Signo) w l lc rgb 'blue' dt 2 lw 3,\
mercator(orto(x,b1+1*15)) tit sprintf("no loop orto a %02d signo %d",1,Signo) w l lc rgb 'blue' dt 2 lw 3,\
mercator(orto(x,b1+2*15)) tit sprintf("no loop orto a %02d signo %d",2,Signo) w l lc rgb 'blue' dt 2 lw 3,\
mercator(orto(x,b1+3*15)) tit sprintf("no loop orto a %02d signo %d",3,Signo) w l lc rgb 'blue' dt 2 lw 3,\
mercator(orto(x,b1+4*15)) tit sprintf("no loop orto a %02d signo %d",4,Signo) w l lc rgb 'blue' dt 2 lw 3,\
mercator(orto(x,b1+5*15)) tit sprintf("no loop orto a %02d signo %d",5,Signo) w l lc rgb 'blue' dt 2 lw 3,\
mercator(orto(x,b1+0*15)) tit sprintf("no loop orto a %02d signo %d",0,Signo) w l lc rgb 'blue' dt 2 lw 3,\
for-loop(第 6 行)不起作用。逐行调用(第 7-12 行)确实有效。
以及从set table获得的输出,每次迭代的第一行
# Curve 43 of 104, 100 points FIRST iteration
# Curve title: "orto a 01 signo 1"
# x y type
-22.5 0.874361° i
-21.9697 0.887919° i
-21.4394 0.901287° i
-20.9091 0.914467° i
# Curve 44 of 104, 100 points SECOND iter
# Curve title: "orto a 02 signo 1"
# x y type
-22.5 0.407722° i
-21.9697 0.426936° i
-21.4394 0.445968° i
-20.9091 0.464814° i
# Curve 45 of 104, 100 points THIRD iter (REPEATS 2nd)
# Curve title: "orto a 03 signo 1"
# x y type
-22.5 0.407722° i
-21.9697 0.426936° i
-21.4394 0.445968° i
-20.9091 0.464814° i
# Curve 46 of 104, 100 points FOURTH iter (repeats 2nd)
# Curve title: "orto a 04 signo 1"
# x y type
-22.5 0.407722° i
-21.9697 0.426936° i
-21.4394 0.445968° i
-20.9091 0.464814° i
# Curve 47 of 104, 100 points FIFTH iter (repeats 2nd)
# Curve title: "orto a 05 signo 1"
# x y type
-22.5 0.407722° i
-21.9697 0.426936° i
-21.4394 0.445968° i
-20.9091 0.464814° i
【问题讨论】:
-
可能与
i是一个整数这一事实有关,因此如果函数f执行任何算术运算,例如除法等,结果可能不是预期的 - 可能您尝试使用f(x, real(i))来将i显式转换为浮动? -
不错。我希望它会奏效。但它失败了。我什至把 f 内的所有整数都变成了实数。它也没有工作。
-
您能否发布相关功能和/或更完整的示例?否则很难说可能出了什么问题……
-
当然。首先是墨卡托proj 公式
mercator(lat)=log(tan(180/4.0+lat/2.0))(角度单位)和终结线公式terminator(x,y)=(x-y)<0?atan(cos(x-y)/tan(23.5)):1/0然后函数是f(x,i)=mercator(terminator(x,b0+i*15)),其中b0是一个实常数。我试过real(i)和15.0或real(15),没有成功。 -
b0的值是多少,你的x坐标的范围是多少?更好的是:你能提供一个minimal, complete, and verifiable example 吗?我假设对于x、i和b0的某些值,您的函数未定义。