我正在尝试用Python绘制一个图表,使用的是Gnuplot。我很难找到任何指南/教程如何开始。
我想知道的是:哪些文件/程序是必需的?(我使用的是Ubuntu),我从哪里开始?
如果有人能推荐一个好的教程,我将不胜感激!
谢谢!
发布于 2011-11-10 17:23:34
你可以试试gnuplot.py。它是我过去使用过的gnuplot的接口。在该网站中,您有一些指示,并且在发行版中有一些示例脚本。
事实上,从python直接运行gnuplot非常容易。gnuplot.py源代码将为您提供有价值的提示。另请参阅here和here以了解其他替代方法。
按照其他人的建议,另一种方法是使用matplotlib。Matplotlib很棒,我把它作为我主要的可视化类库。缺点是处理大量数据会变得很慢。在这种情况下,gnuplot是一个很好的选择。
发布于 2020-03-11 12:01:18
作为gnuplot的粉丝,我使用这个gnuplot包装器https://github.com/mzechmeister/python/wiki/gplot.py。
下面是一个演示片段
from gplot import *
gplot.term('wxt')
gplot.title('"gplot.py"').grid()
gplot.xlabel('"time"')
gplot([1,2,0,4,3.5], 'w l, sin(x), "<seq 10" us 1:(cos($1))')
发布于 2020-10-25 18:43:18
大约10年后,让我将注意力转向autogpy or Autognuplotpy
。
Autogpy的目标是从python中生成完整的gnuplot脚本(以及适当的转储数据)。
例如,python代码
import autogpy
import numpy as np
xx = np.linspace(0,6,100)
yy = np.sin(xx)
zz = np.cos(xx)
with autogpy.AutogpyFigure("test_figure") as figure:
# gnuplot-like syntax
figure.plot(r'with lines t "sin"',xx,yy)
# matplotlib-like syntax
figure.plot(xx,zz,u='1:2',w='lines',label='cos')
生成gnuplot脚本
set terminal epslatex size 9.9cm,8.cm color colortext standalone 'phv,12 ' linewidth 2
set output 'fig.latex.nice/plot_out.tex'
p "fig__0__.dat" with lines t "sin",\
"fig__1__.dat" u 1:2 with lines t "cos"
并转储可读数据。
支持latex,tiks和png终端,但可以很容易地扩展到更多。
免责声明:我是作者。
https://stackoverflow.com/questions/8077099
复制相似问题