GNUPlot:自动绘制标准中的所有列,没有额外的 logic/semantic 噪音
GNUPlot: Auto-plot all columns from standard in without extra logic/semantic noise
假设我有以下文件:
0 a b c
1 1 2 2
2 4 4 2
3 8 6 2
我想从命令行发送它:
cat foofile | gnuplot -e 'file="/dev/stdin"' plot.p
使用以下绘图文件:
set key outside
plot for [col=2:4] file using 0:col with lines title columnheader
现在,假设我想向 GNUPlot 发送一个 任意 列文件,其中包含 1:N 列中的任意位置,其中 N 是任意的。
因为我是从 GNUPlot 中打开一个管道,所以我似乎无法从中读取以确定列数。我如何告诉 GNUPlot(以一种干净的方式)简单地绘制每一列,直到有 none 剩余要绘制?
plot for [col=2:*] file using 0:col with lines title columnheader
但是,如果您知道文件名是什么以便发出 "cat" 命令,您最好将文件名传递给 gnuplot 而不是使用管道。
gnuplot -e 'file="foofile"' plot.p
或者,您可以通过 /dev/stdin 以外的渠道提供输入。以下是 piped-data
文档部分的摘录:
On systems with an fdopen() function, data can be read from an arbitrary file
descriptor attached to either a file or pipe. To read from file descriptor
`n` use `'<&n'`. This allows you to easily pipe in several data files in a
single call from a POSIX shell:
$ gnuplot -p -e "plot '<&3', '<&4'" 3<data-3 4<data-4
$ ./gnuplot 5< <(myprogram -with -options)
gnuplot> plot '<&5'
假设我有以下文件:
0 a b c
1 1 2 2
2 4 4 2
3 8 6 2
我想从命令行发送它:
cat foofile | gnuplot -e 'file="/dev/stdin"' plot.p
使用以下绘图文件:
set key outside
plot for [col=2:4] file using 0:col with lines title columnheader
现在,假设我想向 GNUPlot 发送一个 任意 列文件,其中包含 1:N 列中的任意位置,其中 N 是任意的。
因为我是从 GNUPlot 中打开一个管道,所以我似乎无法从中读取以确定列数。我如何告诉 GNUPlot(以一种干净的方式)简单地绘制每一列,直到有 none 剩余要绘制?
plot for [col=2:*] file using 0:col with lines title columnheader
但是,如果您知道文件名是什么以便发出 "cat" 命令,您最好将文件名传递给 gnuplot 而不是使用管道。
gnuplot -e 'file="foofile"' plot.p
或者,您可以通过 /dev/stdin 以外的渠道提供输入。以下是 piped-data
文档部分的摘录:
On systems with an fdopen() function, data can be read from an arbitrary file
descriptor attached to either a file or pipe. To read from file descriptor
`n` use `'<&n'`. This allows you to easily pipe in several data files in a
single call from a POSIX shell:
$ gnuplot -p -e "plot '<&3', '<&4'" 3<data-3 4<data-4
$ ./gnuplot 5< <(myprogram -with -options)
gnuplot> plot '<&5'