GridSpec¶
-
class
GridSpec
(figure, nrows=1, ncols=1, **kwargs)[source]¶ Bases:
matplotlib.gridspec.GridSpec
Matplotlib
GridSpec
subclass that allows for grids with variable spacing between successive rows and columns of axes. This is done by drawingnrows * 2 + 1
andncols * 2 + 1
GridSpec
rows and columns, settingwspace
andhspace
to0
, and masking out every other row and column of theGridSpec
, so they act as “spaces”. These “spaces” are then allowed to vary in width using the builtinwidth_ratios
andheight_ratios
properties.Note
In a future version, this class will natively support variable spacing between successive rows and columns without the obfuscation. It will also support specifying spaces in physical units via
units
.- Parameters
figure (
Figure
) – The figure instance filled by this gridspec. UnlikeGridSpec
, this argument is required.nrows, ncols (int, optional) – The number of rows and columns on the subplot grid.
hspace, wspace (float or list of float) – The vertical and horizontal spacing between rows and columns of subplots, respectively. In
subplots
,wspace
andhspace
are in physical units. When callingGridSpec
directly, values are scaled relative to the average subplot height or width.If float, the spacing is identical between all rows and columns. If list of float, the length of the lists must equal
nrows-1
andncols-1
, respectively.height_ratios, width_ratios (list of float) – Ratios for the relative heights and widths for rows and columns of subplots, respectively. For example,
width_ratios=(1,2)
scales a 2-column gridspec so that the second column is twice as wide as the first column.left, right, top, bottom (float or str) – Passed to
GridSpec
, denotes the margin positions in figure-relative coordinates.
- Other Parameters
**kwargs – Passed to
GridSpec
.
Methods Summary
__getitem__
(key)Magic obfuscation that renders
GridSpec
rows and columns designated as ‘spaces’ inaccessible.Returns the number of active rows and columns, i.e.
Returns height ratios excluding slots allocated for spaces.
Returns width ratios excluding slots allocated for spaces.
Returns row ratios allocated for spaces.
Returns left, bottom, right, top values.
Returns column ratios allocated for spaces.
update
(**kwargs)Update the gridspec with arbitrary initialization keyword arguments then apply those updates to every figure using this gridspec.