课程评价 (0)

请对课程作出评价:
0/300

学员评价

暂无精选评价
20分钟

container Artist:

a. Figure

  1. matplotlib.figure.Figure是最顶层的container Artist,它包含了图表中的所有元素。
    • Figure.patch属性:Figure的背景矩形
    • Figure.axes属性:持有的一个Axes实例的列表(包括Subplot)
    • Figure.images属性:持有的一个FigureImages patch列表
    • Figure.lines属性:持有一个Line2D实例的列表(很少使用)
    • Figure.legends属性:持有的一个Figure Legend实例列表(不同于Axes.legends)
    • Figure.patches属性:持有的一个Figure pathes实例列表(很少使用)
    • Figure.texts属性:持有的Figure Text实例列表

    其他的属性:

    • Figure.figsize属性:图像的尺寸,(w,h),以英寸为单位
    • Figure.dpi属性:图像分辨率
    • Figure.facecolor属性:背景色
    • Figure.edgecolor属性:edge color
    • Figure.linewidthedge linewidth
    • Figure.frameon:如果为False,则不绘制图像
    • Figure.subplotpars:一个SubplotParams实例
    • Figure.tight_layout:如果为False,则使用subplotpars;否则使用tight_layout()调整subplot parameters

2. 当你执行Figure.add_subplot()或者Figure.add_axes()时,这些新建的Axes都被添加到Figure.axes列表中。

3. 由于Figure维持了current axes,因此你不应该手动的从Figure.axes列表中添加删除元素,而是要通过Figure.add_subplot()Figure.add_axes()来添加元素,通过Figure.delaxes()来删除元素。但是你可以迭代或者访问Figure.axes中的Axes,然后修改这个Axes的属性。

4. 可以通过Figure.gca()获取current axes,通过Figure.sca()设置current axes

5. Figure也有它自己的textlinepatchimage。你可以直接通过add primitive语句直接添加。但是注意Figure默认的坐标系是以像素为单位,你可能需要转换成figure坐标系:(0,0)表示左下点,(1,1)表示右上点。

6. 创建Figure的方法:  matplotlib.pyplot.figure(num=None, figsize=None, dpi=None, facecolor=None,  edgecolor=None, frameon=True, FigureClass=<class 'matplotlib.figure.Figure'>,  **kwargs)

  • num:一个整数或者字符串。
    • 若未提供,则创建一个新的figure
    • 如果给出了一个整数,而且某个现有的figure对象的number属性刚好等于这个整数,则激活该figure并且返回该figure;否则创建一个新的figure
    • 如果是个字符串,则创建一个新的figure,并且将window title设置为该字符串。
  • figsize:一对整数的元组。给出了英寸为单位的高度和宽度。默认由rcfigure.figsize给出
  • dpi:一个整数,给出figure的分辨率。默认由rcfigure.dpi给出
  • facecolor:背景色。若未提供,则由rcfigure.facecolor给出
  • edgecolorborder color。若未提供,则由rcfigure.edgecolor给出

返回一个figure