autogpy:autognuplot.py-从python自动生成gnuplot图形(包括脚本和数据)
autogp的Python项目详细描述
autogpy-autognuplot.py
从python自动生成gnuplot图形/脚本/数据。
作者:Alessandro Corbetta,2019年
文档:https://acorbe.github.io/autogpy/
它解决了什么问题?
autogpy
在python中进行数据分析和在gnuplot中发布数据时,消除了烦人的代码/数据重复。使用接近gnuplot的语法,它自动生成gnuplot脚本并适当地转储数据。
在科学界,gnuplot是出版质量图的金标准。python正迅速成为数据分析的首选工具。虽然它提供了几个绘图选项,但在生产中通常首选gnuplot。
功能
- 任何通过gnuplot命令获得的信息都可以生成
plot
- 任何gnuplot状态修改都可以实现
- 多点
plt.hist
类似gnuplot直方图图形生成器- Jupyter笔记本电脑图形预览
- jupyter笔记本gnuplot脚本检查
- Gnuplot终端Epslatex、Tikz/PGFPlot和JPG
- 输出图形位于包含脚本、数据和makefile的文件夹中
- 在生成图形的机器(例如,从更大的数据集)和“纸张书写”机器之间基于scp的简单同步。
在
- Linux/MacOS
- Python3
kwonw问题
- 某些功能需要imagemagick和工作的
gnuplot-tikz.lua
。有些版本可能有漏洞。执行figure.display_fixes()
以显示已知修复。
简而言之
获取autogpy
从pip
pip install autogpy
来源
git clone git@github.com:acorbe/autogpy.git pip install ./autogpy
使用量
importautogpyimportnumpyasnpxx=np.linspace(0,6,100)yy=np.sin(xx)zz=np.cos(xx)figure=autogpy.AutogpyFigure("test_figure","test1")figure.p_generic(r'u 1:2 with lines t "sin"',xx,yy)figure.p_generic(r'u 1:2 with lines t "cos"',xx,zz)figure.generate_gnuplot_file()figure.jupyter_show_pdflatex()# only in jupyter
将生成下图(也出现在Jupyter中)
最重要的是,将在文件夹test_figure
中创建以下源和数据
$ ls test_figure Makefile sync_me.sh test1__0__.dat test1__1__.dat test1__.core.gnu test1__.jpg.gnu test1__.pdflatex_compile.sh test1__.pdflatex.gnu test1__.tikz_compile.sh test1__.tikz.gnu
使用make
可以获得jpg、epsleax和tikz/pgfplot版本的图形。
注意,输入数据已经自动格式化。
检查test1__.pdflatex.gnu
,负责epsleex版本的图,得到:
setterminalepslatexsize9.9cm,8.cmcolorcolortextstandalone'phv,12 'linewidth2setoutput'fig.latex.nice/plot_out.tex'load"test1__.core.gnu";
当test1__.core.gnu
读取:
p"test1__0__.dat"u1:2withlinest"sin",\ "test1__1__.dat"u1:2withlinest"cos"