gnuplot stdin,如何绘制两条线? [英] gnuplot stdin, how to plot two lines?

查看:191
本文介绍了gnuplot stdin,如何绘制两条线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用从stdin提取的数据生成一条包含两行的图.我有一个文件"test.csv":

I'm trying to produce a plot with two lines using data taken from stdin. I have a file "test.csv":

0,1.1,2
1,2,3
2,6,4
4,4.6,5
5,5,6

我一直试图用类似的命令来绘制它,

I've been trying to plot this with commands like,

$ cat test | gnuplot -p -e "set datafile separator \",\"; plot '-' using 1:2 with lines, '' using 1:3 with lines;"

但是不管我尝试什么,

line 5: warning: Skipping data file with no valid points

我认为这是因为对于第二行,标准输入已经用尽.有没有办法让gnuplot从stdin的每一列获取不同绘图的数据?

I assume this is because for the second line, stdin has already been exhausted. Is there a way to get gnuplot to take data from each column of stdin for different plots?

谢谢.

推荐答案

-"用于指定数据遵循plot命令.因此,如果使用它,则需要执行以下操作:

The "-" is used to specify that the data follows the plot command. So if you use it, you'll need to do something like:

echo "set datafile separator \",\"; plot '-' using 1:2 with lines, '' using 1:3 with lines;" | cat - datafile.dat | gnuplot -p

(上面的引用可能需要转义).

(Quoting above probably needs to be escaped).

您在寻找什么?

plot '< cat -'

现在,您可以执行以下操作:

Now, you can do:

cat test | sed ... | gnuplot -p "plot '< cat -' using ..."

请注意,如果您使用带有plot的选项,则可能需要多次通过stdin输入输入数据,例如:

Note that you might need to feed in the input data via stdin multiple times if you're using options with plot, like so:

cat testfile testfile | gnuplot -p "plot '< cat -' using 1, '' using 2"

在上述情况下,测试文件必须以其中包含唯一字符'e'的行结尾.

In the above case, testfile must end with a line that has the sole character 'e' in it.

手册参考

这篇关于gnuplot stdin,如何绘制两条线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆