gnuplot:使用格式数据类型来分隔数字?

gnuplot: using format data types to seperate a number?

我想分隔给定范围的对数刻度,尤其是最小值。 例如x_min= 0.2 我想得到“2”和“-1”作为 2*10**(-1) 的一部分以供进一步使用。根据手册,这将是 %t 和 %T。我尝试使用 print ("%T", x_min) 但我只是得到 x_min 本身,无论我在打印中设置哪种类型。在 gnuplot 中有什么方法可以做到这一点吗?

@GRSousaJR 已经提到 in the comments. I quickly tested with gnuplot 5.2.8, the inconsistencies are still there. A cumbersome solution is given .

例如:

print gprint("%t",95) 给出 0.95print gprintf("%T",95) 给出 2

所以,95 = 0.95 x 10^2 没有错,但预期的结果是 9.5 x 10^1

但是现在,如果您使用 %.3t 而不是 %t,您将得到 错误的 结果。 也许有人可以解释一下?!

所以总结一下: (它变得有点冗长,因为 gprintf() 只允许一个参数。)

代码:

### inconsistency in gprintf with %t and %T
reset session

array Numbers = [0.95, 9.5, 95, 995, 9995]

print "gprintf with %t"
do for [i=1:|Numbers|] {
    print gprintf("% 8g",Numbers[i])." = ".gprintf("%t",Numbers[i])." x 10^".gprintf("%T",Numbers[i])
}
print "gprintf with %.3t"
do for [i=1:|Numbers|] {
    print gprintf("% 8g",Numbers[i])." = ".gprintf("%.3t",Numbers[i])." x 10^".gprintf("%T",Numbers[i])
}
print "gprintf with %.0t"
do for [i=1:|Numbers|] {
    print gprintf("% 8g",Numbers[i])." = ".gprintf("%.0t",Numbers[i])." x 10^".gprintf("%T",Numbers[i])
}
### end of code

结果:(使用 gnuplot 5.2.8)

gprintf with %t
    0.95 = 9.500000 x 10^-1
     9.5 = 9.500000 x 10^0
      95 = 0.950000 x 10^2    # somehow correct but not the expected result
     995 = 0.995000 x 10^3    # somehow correct but not the expected result
    9995 = 0.999500 x 10^4    # somehow correct but not the expected result
gprintf with %.3t
    0.95 = 9.500 x 10^-1
     9.5 = 9.500 x 10^0
      95 = 9.500 x 10^2    # simply wrong
     995 = 9.950 x 10^3    # simply wrong
    9995 = 9.995 x 10^4    # simply wrong
gprintf with %.0t
    0.95 = 9 x 10^-1
     9.5 = 9 x 10^0
      95 = 1 x 10^2    # somehow ok, rounded. But why not 9 x 10^1, similar to 9.5?
     995 = 1 x 10^3    # ok, rounded
    9995 = 1 x 10^4    # ok, rounded