默认情况下,gnuplot用丢失数据的直线代替曲线。有没有办法更改此范围的线型?例如,整个曲线用连续线打印,而缺失数据用虚线代替?
set datafile missing "?"
set term wxt dashed
plot "1.txt" using ($1):($2) with lines title "line", "<grep -A1 -B1 '?' 1.txt" w lines lt 2 lc 1 title "missing"
:~$ cat 1.txt
1 2
2 3
3 9
4 ?
5 6
6 7
将缺少的数据标记为?
。
using ($1):($2)
使遗漏的数据被跳过(图中的空格)。
执行grep
选择一系列数据,包括前面的每行-A1
和后面的-B1
每行?
,用dashed
线(lt 2
)绘制。
:~$ cat 1.txt
1 2 3
2 3 ?
3 9 5
4 ? 2
5 6 7
6 7 4
将最后一个gnuplot
命令更改为:
plot for [i=1:2] "1.txt" using ($1):(column(i+1)) with lines lt 1 lc i title "line".i, for [i=1:2] "<awk -v u=$((".i."+1)) '{printf $1\" \";print $u}' 1.txt | grep -A1 -B1 '?'" using 1:2 w lines lt 2 lc i title "missing".i
for [i=1:2]
是gnuplot
迭代(循环),进行两次(三列文件)。更改2
为您的column count - 1
。
要评论的另一件事是"<awk -v u=$((".i."+1)) '{printf $1\" \";print $u}' ..."
:这里我们将shell命令括在中""
,并用串联字符串。.
这是将gnuploti
变量传递给执行的shell的一种方式-我们将字符串与awk
命令的第一部分和命令i
的第二部分进行连接awk
。
我们每次都打印到文件的列:第一个-printf $1
和i+1
st(又名u
'th,我们将其作为参数传递给awk
)。\" \"
只是一个空格,应避免使用双引号。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句