python - 从 python 调用 gnuplot

标签 python gnuplot

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

相关文章:

C++将字符串传递到管道中以传递给gnuplot

python - Ipython Select Widget - 不止一个选择

python - 如何在此脚本中找到查找结果以通过电子邮件发送

python - 在 Python 中修改格式化数字中的前导字符?

gnuplot - 如何在 gnuplot 中绝对单元格引用

vba - GNUPLOT 与 VBA - STDERR 去了哪里?

python - 使用日期值设置 xticks 间隔

python - ImportError:没有名为 primes 的模块

linux - 带有 CSV 的 gnuplot 中的堆叠条形图

gnuplot - 如何在 gnuscript 中循环使用 grep 命令