gpt4 book ai didi

python - 从 python 调用 gnuplot

转载 作者:IT老高 更新时间:2023-10-28 20:49:33 25 4
gpt4 key购买 nike

我有一个 python 脚本,经过一些计算后会生成两个格式化为 gnuplot 输入的数据文件。

如何从 python 中“调用”gnuplot?

我想将以下 python 字符串作为输入发送到 gnuplot:

"plot '%s' with lines, '%s' with points;" % (eout,nout)

其中 'eout' 和 'nout' 是两个文件名。

PS:我宁愿不使用额外的 python 模块(例如 gnuplot-py),只使用标准 API。

谢谢

最佳答案

subprocess模块让你调用其他程序:

import subprocess
plot = subprocess.Popen(['gnuplot'], stdin=subprocess.PIPE)
plot.communicate("plot '%s' with lines, '%s' with points;" % (eout,nout))

关于python - 从 python 调用 gnuplot,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2161932/

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