matplotlib.gridspec
¶gridspec
is a module which specifies the location
of the subplot in the figure.
GridSpec
- specifies the geometry of the grid that a subplot will be placed. The number of rows and number of columns of the grid need to be set. Optionally, the subplot layout parameters (e.g., left, right, etc.) can be tuned.
SubplotSpec
- specifies the location of the subplot in the given GridSpec.
matplotlib.gridspec.
GridSpec
(nrows, ncols, left=None, bottom=None, right=None, top=None, wspace=None, hspace=None, width_ratios=None, height_ratios=None)¶Bases: matplotlib.gridspec.GridSpecBase
A class that specifies the geometry of the grid that a subplot will be placed. The location of grid is determined by similar way as the SubplotParams.
The number of rows and number of columns of the grid need to be set. Optionally, the subplot layout parameters (e.g., left, right, etc.) can be tuned.
get_subplot_params
(fig=None)¶return a dictionary of subplot layout parameters. The default parameters are from rcParams unless a figure attribute is set.
locally_modified_subplot_params
()¶tight_layout
(fig, renderer=None, pad=1.08, h_pad=None, w_pad=None, rect=None)¶Adjust subplot parameters to give specified padding.
Parameters:
pad_inches
.update
(**kwargs)¶Update the current values. If any kwarg is None, default to the current value, if set, otherwise to rc.
matplotlib.gridspec.
GridSpecBase
(nrows, ncols, height_ratios=None, width_ratios=None)¶Bases: object
A base class of GridSpec that specifies the geometry of the grid that a subplot will be placed.
The number of rows and number of columns of the grid need to be set. Optionally, the ratio of heights and widths of rows and columns can be specified.
get_geometry
()¶get the geometry of the grid, e.g., 2,3
get_grid_positions
(fig)¶return lists of bottom and top position of rows, left and right positions of columns.
get_height_ratios
()¶get_subplot_params
(fig=None)¶get_width_ratios
()¶new_subplotspec
(loc, rowspan=1, colspan=1)¶create and return a SuplotSpec instance.
set_height_ratios
(height_ratios)¶set_width_ratios
(width_ratios)¶matplotlib.gridspec.
GridSpecFromSubplotSpec
(nrows, ncols, subplot_spec, wspace=None, hspace=None, height_ratios=None, width_ratios=None)¶Bases: matplotlib.gridspec.GridSpecBase
GridSpec whose subplot layout parameters are inherited from the location specified by a given SubplotSpec.
The number of rows and number of columns of the grid need to be set. An instance of SubplotSpec is also needed to be set from which the layout parameters will be inherited. The wspace and hspace of the layout can be optionally specified or the default values (from the figure or rcParams) will be used.
get_subplot_params
(fig=None)¶return a dictionary of subplot layout parameters.
get_topmost_subplotspec
()¶get the topmost SubplotSpec instance associated with the subplot
matplotlib.gridspec.
SubplotSpec
(gridspec, num1, num2=None)¶Bases: object
specifies the location of the subplot in the given GridSpec.
The subplot will occupy the num1-th cell of the given gridspec. If num2 is provided, the subplot will span between num1-th cell and num2-th cell.
The index stars from 0.
get_geometry
()¶get the subplot geometry, e.g., 2,2,3. Unlike SuplorParams, index is 0-based
get_gridspec
()¶get_position
(fig, return_all=False)¶update the subplot position from fig.subplotpars
get_topmost_subplotspec
()¶get the topmost SubplotSpec instance associated with the subplot