gnuplot的脚本在Windows操作系统上 [英] Script Gnuplot on windows OS
问题描述
我想曲线的生成从数据文件的列表自动化。
I would like to automate the generation of graphs from a list of data files.
详细信息:
我有我的包含所有数据文件的目录。我需要生成用于每个文件(数百)的曲线图。我有一个gnuplot的文件来生成一个图,但数据文件的名称被指定到gnuplot的脚本。
More details : I have a directory that contain all my data files. I need to generate a graph for each of these files (hundreds). I have a gnuplot file to generate one graph but the name of the data file is specified into the gnuplot script.
例如:
plot 'myfile' index 1 using 1:2 with linespoints pointtype 2 linecolor rgb "green" title "leg"
我需要能够通过,可以在我的目录中的所有文件进行迭代变量名称取代MYFILE。
I need to be able to replace "myfile" by a variable name that can be iterated on all the files of my directory.
推荐答案
您可以与下面的命令(Windows)中的批处理文件:
You could have a (Windows) batch file with the following command:
for %%G in (*.dat) do gnuplot.exe -e "fn='%%G'" script
这将运行gnuplot的(和剧本的),在当前目录下的每个 .DAT
文件。
This will run gnuplot (and script) for every .dat
file in the current directory.
的 -e
开关用于通过命令行来输入变量一>(这里的文件名,由引号包围的情况下,它包含空格)。
The -e
switch is used to input variables via command line (here the filename, surrounded by quotes in case it contains spaces).
如果您想直接从shell中运行此命令(如批处理文件中反对),每两对删除%象征之一。
If you want to run this command directly from the shell (as opposed to within a batch file), remove one of the % symbols from each of the two pairs.
在脚本文件:
plot fn index 1 using 1:2 with linespoints pointtype 2 linecolor rgb "green" title "leg"
如果数据文件有一个标准化的名称(例如 data1.dat
, data2.dat
.. )看看<一个href=\"http://stackoverflow.com/a/14947085/3235496\">http://stackoverflow.com/a/14947085/3235496
If the data files have a "normalized" name (e.g. data1.dat
, data2.dat
...) take a look at http://stackoverflow.com/a/14947085/3235496
这篇关于gnuplot的脚本在Windows操作系统上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!