matplotlib.figure.Figure#

class matplotlib.figure.Figure(figsize=None, dpi=None, *, facecolor=None, edgecolor=None, linewidth=0.0, frameon=None, subplotpars=None, tight_layout=None, constrained_layout=None, layout=None, **kwargs)[源代码][源代码]#

所有绘图元素的顶级容器。

参见 matplotlib.figure 以获取类方法的索引。

属性:
补丁

表示图形背景补丁的 Rectangle 实例。

suppressComposite

对于多张图片,图表将根据渲染器 option_image_nocomposite 函数生成复合图像。如果 suppressComposite 是布尔值,这将覆盖渲染器。

参数:
figsize : 2个浮点数的元组, 默认值: rcParams["figure.figsize"] (default: [6.4, 4.8])2-tuple of floats, 默认值:

图的尺寸 (宽度, 高度) 以英寸为单位。

dpi : float, 默认值: rcParams["figure.dpi"] (default: 100.0)浮点数, 默认:

每英寸点数。

facecolor : 默认值: rcParams["figure.facecolor"] (default: 'white')默认:

图形补丁面颜色。

edgecolor : 默认值: rcParams["figure.edgecolor"] (default: 'white')默认:

图形补丁边缘颜色。

行宽浮动

框架的线宽(即图形补丁的边缘线宽)。

frameon : bool, 默认值: rcParams["figure.frameon"] (default: True)bool, 默认值:

如果 False,则抑制绘制图形背景补丁。

subplotpars子图参数

子图参数。如果没有给出,则使用默认的子图参数 rcParams["figure.subplot.*"]

tight_layout : bool 或 dict, 默认值: rcParams["figure.autolayout"] (default: False)布尔值或字典,默认值:

是否使用紧凑布局机制。参见 set_tight_layout

不鼓励

不鼓励使用此参数。对于 tight_layout=True 的常见情况,请改用 layout='tight',否则请使用 set_tight_layout

constrained_layout : bool, 默认值: rcParams["figure.constrained_layout.use"] (default: False)bool, 默认值:

这等同于 layout='constrained'

不鼓励

不推荐使用此参数。请改用 layout='constrained'

布局 : {'constrained', 'compressed', 'tight', 'none', LayoutEngine, None}, 默认: None{'constrained', 'compressed', 'tight', 'none',}

用于定位绘图元素以避免重叠 Axes 装饰(标签、刻度等)的布局机制。请注意,布局管理器可能会带来显著的性能损失。

  • 'constrained': 约束布局求解器调整轴的大小以避免轴装饰的重叠。可以处理复杂的图形布局和颜色条,因此推荐使用。

    参见 约束布局指南 的示例。

  • 'compressed': 使用与 'constrained' 相同的算法,但去除了固定纵横比 Axes 之间的额外空间。最适合简单的 Axes 网格。

  • 'tight': 使用紧凑布局机制。这是一个相对简单的算法,调整子图参数以便装饰不会重叠。

    参见 紧凑布局指南 的示例。

  • 'none': 不使用布局引擎。

  • 一个 LayoutEngine 实例。内置的布局类是 ConstrainedLayoutEngineTightLayoutEngine,通过 'constrained' 和 'tight' 更容易访问。传递一个实例允许第三方提供他们自己的布局引擎。

如果没有指定,则回退到使用参数 tight_layoutconstrained_layout,包括它们的配置默认值 rcParams["figure.autolayout"] (default: False) 和 rcParams["figure.constrained_layout.use"] (default: False)。

其他参数:
**kwargs : Figure 属性, 可选图形属性,可选

属性

描述

agg_filter

一个过滤函数,它接收一个 (m, n, 3) 的浮点数组和一个 dpi 值,并返回一个 (m, n, 3) 数组和两个从图像左下角开始的偏移量

alpha

标量或无

animated

布尔

画布

FigureCanvas

clip_box

BboxBase 或 None

clip_on

布尔

clip_path

补丁或(路径,变换)或无

constrained_layout

未知

constrained_layout_pads

未知

dpi

浮动

edgecolor

color

facecolor

color

figheight

浮动

figure

未知

figwidth

浮动

frameon

布尔

gid

str

in_layout

布尔

标签

对象

layout_engine

{'constrained', 'compressed', 'tight', 'none', LayoutEngine, None}

linewidth

数字

鼠标悬停

布尔

path_effects

AbstractPathEffect 列表

picker

None 或 bool 或 float 或 callable

光栅化

布尔

size_inches

(float, float) 或 float

sketch_params

(scale: float, length: float, randomness: float)

snap

布尔值或无

tight_layout

未知

transform

Transform

url

str

可见

布尔

zorder

浮动