GNUPlot:自动绘制标准in中的所有列,无需额外的逻辑/语义干扰

GNUPlot:自动绘制标准in中的所有列,无需额外的逻辑/语义干扰,gnuplot,Gnuplot,假设我有以下文件: 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是任意的 由于我正在从GNU

假设我有以下文件:

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(以一种干净的方式)简单地绘制每一列,直到没有任何列可以绘制

  plot for [col=2:*] file using 0:col with lines title columnheader
但是,如果您知道文件名是什么以便发出“cat”命令,那么最好将文件名传递给gnuplot,而不是使用管道

  gnuplot -e 'file="foofile"' plot.p
或者,您可以通过/dev/stdin以外的通道提供输入。以下是
管道数据的文档部分摘录:

 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'
在具有fdopen()函数的系统上,可以从任意文件读取数据
附加到文件或管道的描述符。从文件描述符中读取

`n`use``这是一个非常小的、最小的、可验证的例子,说明了从一个非常大的数据立方体到一组非常大的绘图--我不想为每个绘图都将数据集写入磁盘。我想我在前面遇到了你的答案,我仍然需要在磁盘上读写才能完成这一任务。我认为答案可能涉及以某种方式将标准输入读入gnuplot中的内存。否则,我可能不得不使用python和matplotlib。您不仅限于从stdin读取数据。您可以打开任意数量的输入通道,并根据它们提供的数据进行绘图。详细信息必须依赖于shell和操作系统,但请参见
帮助管道数据中提供的示例。从添加到上一个答案的文档中提取。