使用gnuplot同时绘制目录中的所有文件? [英] Plot all files in a directory simultanously with gnuplot?
问题描述
我想做与此问题类似的事情: gnuplot:在单个图形中绘制来自多个输入文件的数据.
I want to do something similar to this question: gnuplot : plotting data from multiple input files in a single graph.
我想同时绘制目录中的所有所有文件,而不必明确地写出它们的名称.所有文件的列号均相同.我该怎么办?
I want to plot simultaneously all the files in a directory, without having to explicitly write their names. The column numbers are the same for all the files. What can I do?
不执行plot for [file in *] file u 3:2
.
我也不希望每个文件都有不同的图例.所有文件中的所有点都应被视为相同,就好像它们都来自单个文件一样.
Also, I don't want each file to have a different legend. All points from all files should be treated the same, as if they all came from a single file.
推荐答案
您可以尝试以下方法:
a=system('a=`tempfile`;cat *.dat > $a;echo "$a"')
plot a u 3:2
这使用命令行tempfile
命令来创建安全,唯一且可丢弃的临时文件.它将所有数据文件混搭到该文件中.然后,它回显文件的名称,以便gnuplot可以检索它.然后,Gnuplot绘制事物.
This uses the command line tempfile
command to create a safe, unique, and disposable temporary file. It mashes all of the data files into this file. It then echoes the file's name so gnuplot can retrieve it. Gnuplot then plots things.
担心标题行吗?试试这个:
Worried about header lines? Try this:
a=system('a=`tempfile`;cat *.dat | grep "^\s*[0-9]" > $a;echo "$a"')
正则表达式^\s*[0-9]
将匹配所有以任意数量的空格后跟数字开头的行.
The regular expression ^\s*[0-9]
will match all lines which begin with any amount of whitespace followed by a number.
这篇关于使用gnuplot同时绘制目录中的所有文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!