我有一个 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/