时,“x范围无效”我在linux上学习gnuplot。我data.tsv看起来是这样的:
1480420804 2016-11-29 04:00:04 -0800 foo1 $123.00 bar1
1480507205 2016-11-30 04:00:05 -0800 foo2 $124.25 bar2
1480593604 2016-12-01 04:00:04 -0800 foo3 $122.75 bar3
我使用#1列(纪元以来秒)为X,和第4列(价格)为Y.
这是我的gnuplot脚本:
#!/usr/bin/gnuplot
set terminal png notransparent interlace size 640,480
set output "output.png"
set datafile separator tab
set xdata time
set timefmt "%s"
set format x "%4Y-%02m-%02d"
plot "data.tsv" using 1:4 title "Blah"
当我尝试运行它,我得到以下错误:
"./test.gp", line 9: warning: Skipping data file with no valid points
plot "data.tsv" using 1:4 title "Blah"
^
"./test.gp", line 9: x range is invalid
但是,如果我从一开始删除所有的美元符号我的data.tsv文件中的第4列,然后一切正常。
我的问题:有没有办法让gnuplot接受或跳过第4列价格中的“$”?
一个sed搜索命令的语法是'S /'(模式)'/ '(替换)'/'。 sed命令's/\ $ // g'意味着搜索('s')正则表达式'\ $'(一个转义的''',一个字符)并将其替换为一个空字符串。最后的“g”意味着“全球化”,这不仅仅是线上的第一次出现。 – e0k