我正在编写一个快速而肮脏的脚本来动态生成绘图.我使用下面的代码(来自Matplotlib文档)作为起点:
from pylab import figure, axes, pie, title, show
# Make a square figure and axes
figure(1, figsize=(6, 6))
ax = axes([0.1, 0.1, 0.8, 0.8])
labels = 'Frogs', 'Hogs', 'Dogs', 'Logs'
fracs = [15, 30, 45, 10]
explode = (0, 0.05, 0, 0)
pie(fracs, explode=explode, labels=labels, autopct='%1.1f%%', shadow=True)
title('Raining Hogs and Dogs', bbox={'facecolor': '0.8', 'pad': 5})
show() # Actually, don't show, just save to foo.png
Run Code Online (Sandbox Code Playgroud)
我不想在GUI上显示绘图,相反,我想将绘图保存到文件(例如foo.png),因此,例如,它可以在批处理脚本中使用.我怎么做?
我看到我可以用Python 绘图:
import matplotlib
matplotlib.pyplot.plot(...)
Run Code Online (Sandbox Code Playgroud)
要么:
import pylab
pylab.plot(...)
Run Code Online (Sandbox Code Playgroud)
这两个都使用相同的matplotlib绘图代码.
那么,Python社区推荐哪一种作为更好的绘图方法呢?为什么?
我用谷歌搜索了,并没有看到哪里得到pylab.
我错过了什么?
谢谢!
我参观了PyLab的scipy网站.我在那里找不到它的文档.该matplotlib网站也没有提供任何信息.
我在哪里可以找到关于PyLab的教程/文档?