gpt4 book ai didi

gnuplot - 通过管道将绘图数据传输至 gnuplot 脚本

转载 作者:行者123 更新时间:2023-12-02 01:27:27 25 4
gpt4 key购买 nike

我想创建一个包含三个图的 gnuplot。数据应该是内联的(因为我只想

它应该看起来像这样:

https://s22.postimg.cc/qcc94e1i9/test.png

目前我正在使用以下 gnuplot 脚本来创建绘图:

set terminal png
set output "test.png"
plot for[col=2:4] "data.txt" using 1:col title columnheader(col) with lines

文件data.txt是:

Generation Best Worst Average
0 2 1 0
1 3 1 2
2 4 3 3
3 4 3 3
4 6 3 4
5 7 4 5
6 9 6 7
7 10 6 9
8 10 5 6
9 11 6 8
10 12 7 9

我想将 data.txt 通过管道传输到 gnuplot 中,而不是依赖脚本中引用的数据文件。像cat data.txt | 这样的东西gnuplotplot.gnu。原因是,我有几个 data.txt 文件,并且不想为每个文件构建 plot.gnu 文件。

我读到了特殊的 '-' 文件 in this stackoverflow thread我读到 multiple plots in one file 。然而,这需要将数据包含在 gnuplot 代码中,这并不干净。

最佳答案

如果您使用的是 Unix 系统(即不是 Windows),您可以使用 '<cat'而不是'-'从标准输入读取:

plot '<cat' using ...

然后你可以做cat data.txt | gnuplot script.gp 。然而,在您在问题中提到的具体情况下,在 for 循环中的绘图中,您将输入读取三遍。所以通过stdin发送数据是不合适的,因为第一次读取后数据就会消失。

关于gnuplot - 通过管道将绘图数据传输至 gnuplot 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17543386/

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