我找到了 Gnuplot package 的文档对于python来说有点缺乏。我想做像this simple one这样的图像图:
#!/usr/bin/gnuplot
plot '-' matrix with image
4 4 4 1
3 2 1 1
1 2 3 1
0 0 0 0
e
如何创建矩阵并告诉 Gnuplot.py 如何使用它并绘制图像?我认为它是这样的:
#!/usr/bin/python
import Gnuplot as gp
import numpy as np
g = gp.Gnuplot(debug=1)
m = np.matrix('4 4 4 1; 3 2 1 1; 1 2 3 1; 0 0 0 0')
gdat = gp.GridData(m, with_='matrix image', binary=0)
g.plot(gdat)
最佳答案
Gnuplot-py 是 gnuplot 的一个非常简约的包装器,因此您必须提供大量原始命令。请尝试以下操作:
#!/usr/bin/python
import Gnuplot as gp
import numpy as np
g = gp.Gnuplot(debug=1)
m = np.matrix('4 4 4 1; 3 2 1 1; 1 2 3 1; 0 0 0 0')
gdat = gp.GridData(m, inline=True, binary=False)
g('set style data image')
g.plot(gdat)
我目前无法对此进行测试,但它应该可以帮助您开始。
关于python - 如何在 python 的 gnuplot 模块中绘制图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32206533/