更新时间:2021-07-11 04:20:13
在这种情况下,我认为没有直接的方法可以告诉gnuplot如何解释输入.
I think there is no direct way of telling gnuplot of how to interpret the input in this case.
但是,您可以编写自己的函数,将字符串输入转换为数字
You can, however, write your own function that converts the string-input to numbers
check(x)=(pos=strstrt(x,"k"),\
pos > 0 ? real(substr(x,1,pos-1))*1000 : real(x))
函数check
首先确定字母'k'在输入中的位置. (如果输入x
不包含字母'k',则函数strstrt
返回'0'.)
如果输入中包含字母"k",请输入,丢弃最后一个字母,将剩余部分转换为数字,然后乘以1000.
如果输入不包含"k",则返回输入
The function check
first determines the position of the letter 'k' in the input. (The function strstrt
returns '0' if the input x
does not contain the letter 'k'.)
If the input contains the letter 'k', take the input, discard the last letter, convert the remaining part to a number and multiply it by 1000.
If the input does not contain 'k', return the input
现在您可以绘制数据文件(假设其名称为test
):
Now you can plot the data file (assuming its name is test
):
plot 'test' u 1:(check(stringcolumn(2))) w l
这应该可以完成!