gpt4 book ai didi

windows - 在 Windows 操作系统上编写 Gnuplot 脚本

转载 作者:可可西里 更新时间:2023-11-01 11:18:24 28 4
gpt4 key购买 nike

我想从数据文件列表中自动生成图表。

更多详情:我有一个包含我所有数据文件的目录。我需要为这些文件中的每一个(数百个)生成一个图表。我有一个 gnuplot 文件来生成一个图形,但数据文件的名称在 gnuplot 脚本中指定。

例如:

plot 'myfile' index 1  using 1:2 with linespoints pointtype 2 linecolor rgb "green"  title "leg"

我需要能够用一个变量名替换“myfile”,该变量名可以在我的目录中的所有文件上迭代。

最佳答案

您可以使用以下命令创建 (Windows) 批处理文件:

for %%G in (*.dat) do gnuplot.exe -e "fn='%%G'" script

这将为当前目录中的每个 .dat 文件运行 gnuplot(和 script)。

-e 开关用于 input variables via command line (这里是文件名,如果包含空格,则用引号括起来)。

如果您想直接从 shell 运行此命令(而不是在批处理文件中),请从两对中的每一对中删除一个 % 符号。

在脚本文件中:

plot fn index 1  using 1:2 with linespoints pointtype 2 linecolor rgb "green"  title "leg"

如果数据文件有一个“标准化”名称(例如 data1.datdata2.dat...),请查看 https://stackoverflow.com/a/14947085/3235496

关于windows - 在 Windows 操作系统上编写 Gnuplot 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26356883/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com