matplotlib.gridspec.SubplotSpec

class matplotlib.gridspec.SubplotSpec(gridspec, num1, num2=None)[源代码]

基类:object

中指定子批次的位置 GridSpec .

注解

很可能,您永远不会实例化 SubplotSpec 你自己。相反,您通常会从 GridSpec 使用项目访问。

参数:
GRIDSPECGridSpecGridSpec

引用子规范的网格。

num1,num2利息

子批将占用给定gridspec的第num1个单元格。如果提供num2,则子批将在第num1个单元格和第num2个单元格之间跨越 包容的 .

索引从0开始。

__dict__ = mappingproxy({'__module__': 'matplotlib.gridspec', '__doc__': "\n Specifies the location of a subplot in a `GridSpec`.\n\n .. note::\n\n Likely, you'll never instantiate a `SubplotSpec` yourself. Instead you\n will typically obtain one from a `GridSpec` using item-access.\n\n Parameters\n ----------\n gridspec : `~matplotlib.gridspec.GridSpec`\n The GridSpec, which the subplot is referencing.\n num1, num2 : int\n The subplot will occupy the num1-th cell of the given\n gridspec. If num2 is provided, the subplot will span between\n num1-th cell and num2-th cell *inclusive*.\n\n The index starts from 0.\n ", '__init__': <function SubplotSpec.__init__>, '__repr__': <function SubplotSpec.__repr__>, '_from_subplot_args': <staticmethod object>, 'num2': <property object>, '__getstate__': <function SubplotSpec.__getstate__>, 'get_gridspec': <function SubplotSpec.get_gridspec>, 'get_geometry': <function SubplotSpec.get_geometry>, 'get_rows_columns': <function SubplotSpec.get_rows_columns>, 'rowspan': <property object>, 'colspan': <property object>, 'get_position': <function SubplotSpec.get_position>, 'get_topmost_subplotspec': <function SubplotSpec.get_topmost_subplotspec>, '__eq__': <function SubplotSpec.__eq__>, '__hash__': <function SubplotSpec.__hash__>, 'subgridspec': <function SubplotSpec.subgridspec>, '__dict__': <attribute '__dict__' of 'SubplotSpec' objects>, '__weakref__': <attribute '__weakref__' of 'SubplotSpec' objects>, '__annotations__': {}})
__eq__(other)[源代码]

如果两个子批次在同一位置上引用相同的位置,则认为它们相等 GridSpec .

__getstate__()[源代码]
__hash__()[源代码]

返回哈希(self)。

__init__(gridspec, num1, num2=None)[源代码]

初始化自身。请参阅帮助(键入(self))以获得准确的签名。

__module__ = 'matplotlib.gridspec'
__repr__()[源代码]

返回repr(self)。

__weakref__

对象的弱引用列表(如果已定义)

property colspan

此子批次跨越的列,作为 range 对象。

get_geometry()[源代码]

以元组形式返回子批次几何体 (n_rows, n_cols, start, stop) .

指数 开始stop 在中定义子批次的范围 GridSpec . stop 包含(即单个单元格 start == stop

get_gridspec()[源代码]
get_position(figure, return_all=False)[源代码]

更新子批次位置 figure.subplotpars .

get_rows_columns()[源代码]

[Deprecated] 以元组形式返回子批次的行和列号 (n_rows, n_cols, row_start, row_stop, col_start, col_stop) .

笔记

3.3 版后已移除.

get_topmost_subplotspec()[源代码]

返回最上面的 SubplotSpec 与子批次关联的实例。

property num2
property rowspan

此子批次跨越的行,如 range 对象。

subgridspec(nrows, ncols, **kwargs)[源代码]

在此子批次中创建一个GridSpec。

创造的 GridSpecFromSubplotSpec 会有这个吗 SubplotSpec 作为父母。

参数:
nrows利息

网格中的行数。

ncols利息

网格中的数字或列。

返回:
GridSpecFromSubplotSpec
其他参数:
**kwargs

所有其他参数都传递给 GridSpecFromSubplotSpec .

实例

在单个子块占用的空间中添加三个子块::

fig = plt.figure()
gs0 = fig.add_gridspec(3, 1)
ax1 = fig.add_subplot(gs0[0])
ax2 = fig.add_subplot(gs0[1])
gssub = gs0[2].subgridspec(1, 3)
for i in range(3):
    fig.add_subplot(gssub[0, i])