matplotlib 学习笔记(1): figure

2018-12-23  本文已影响0人  大王叫我来巡老和山

接下来要写的就是 python 当中的可视化工具,matplotlib ~
个人对这种可视化的包有一种偏爱,所以,边写边回顾,温故而知新~


figure 函数的调用方式如下:

import matplotlib.pyplot as plt
fig = plt.figure()

我们来看一下 figure 的定义,该函数生成并返回一个 figure 对象:

def figure(num=None,  # autoincrement if None, else integer from 1-N
           figsize=None,  # defaults to rc figure.figsize
           dpi=None,  # defaults to rc figure.dpi
           facecolor=None,  # defaults to rc figure.facecolor
           edgecolor=None,  # defaults to rc figure.edgecolor
           frameon=True,
           FigureClass=Figure,
           clear=False,
           **kwargs
           ):

附注:如果你创建了多个figure实例,必须确保你显式的调用 plt.close() 来释放你已经不再使用的 figure 实例。因为只有这样 pylab 才能正确的释放内存。

close(): by itself closes the current figure
close(fig): closes the `.Figure` instance *fig*
close(num): closes the figure number *num*
close(name): where *name* is a string, closes figure with that label
close('all'): closes all the figure windows
上一篇 下一篇

猜你喜欢

热点阅读