GridSpec

class GridSpec(nrows=1, ncols=1, **kwargs)[source]

Bases: matplotlib.gridspec.GridSpec

A GridSpec subclass that permits variable spacing between successive rows and columns and hides “panel slots” from indexing.

Parameters
  • nrows, ncols (int, optional) – The number of rows and columns on the subplot grid.

  • left, right, top, bottom (float or str, optional) – The fixed space between the subplots and the figure edge. Default is None. If float, units are em-widths. If string, interpreted by units. If None, the space is determined automatically based on the font size and axis sharing settings. If rc['subplots.tight'] is True, the space is determined by the tight layout algorithm.

  • wspace, hspace, space (float or str or list thereof, optional) – The fixed space between grid columns, rows, and both, respectively. If float, string, or None, this value is expanded into lists of length ncols - 1 (for wspace) or length nrows - 1 (for hspace). If list, the list must match these lengths. Default is None. If float, units are em-widths. If string, interpreted by units.

    For list elements equal to None, the space is determined automatically based on the font size and axis settings. If rc['subplots.tight'] is True, the space is determined by the tight layout algorithm. Otherwise, a sensible default value is chosen. For example, subplots(ncols=3, tight=True, wspace=(2, None)) fixes the space between columns 1 and 2 but lets the tight layout algorithm determine the space between columns 2 and 3.

  • wratios, hratios (float or list thereof, optional) – Passed to GridSpec, denotes the width and height ratios for the subplot grid. Length of wratios must match the number of rows, and length of hratios must match the number of columns.

  • width_ratios, height_ratios – Aliases for wratios, hratios. Included for consistency with the matplotlib.pyplot.subplots command.

  • wpad, hpad, pad (float or str or list thereof, optional) – The tight layout padding between columns, rows, and both, respectively. Unlike space, these control the padding between subplot content (including text, ticks, etc.) rather than subplot edges. As with space, these can be scalars or arrays optionally containing None. Default is innerpad. If float, units are em-widths. If string, interpreted by units.

  • wequal, hequal, equal (bool, optional) – Whether to make the tight layout algorithm apply equal spacing between columns, rows, or both. Default is False. Ignored if rc.tight is False.

  • outerpad (float or str, optional) – The tight layout padding around the left, right, top, and bottom edges of the figure. Default is rc['subplots.outerpad'] = 0.5. If float, units are em-widths. If string, interpreted by units.

  • innerpad (float or str, optional) – The scalar tight layout padding between columns and rows. Synonymous with pad. Default is rc['subplots.innerpad'] = 1.0. If float, units are em-widths. If string, interpreted by units.

  • panelpad (float or str, optional) – The tight layout padding between subplots and axes panels and between “stacked” panels. Default is rc['subplots.panelpad'] = 0.5. If float, units are em-widths. If string, interpreted by units.

Note

Adding axes panels, axes or figure colorbars, and axes or figure legends quietly augments the gridspec geometry by inserting “panel slots”. However subsequently indexing the gridspec with gs[num] or gs[row, col] will ignore the “panel slots”. This permits adding new subplots by passing gs[num] or gs[row, col] to add_subplot even in the presence of panels. See __getitem__ for details.

Attributes Summary

figure

The proplot.figure.Figure instance uniquely associated with this GridSpec.

Methods Summary

__getitem__(key)

Get a SubplotSpec.

get_geometry()

Return the total number of rows and columns in the grid.

get_grid_positions([figure])

Return the subplot grid positions allowing for variable inter-subplot spacing and using physical units for the spacing terms.

get_panel_geometry()

Return the number of rows and columns allocated for "panel" subplots and not available with gridspec[...] indexing.

get_subplot_geometry()

Return the number of rows and columns allocated for "main" subplots and available with gridspec[...] indexing.

update(**kwargs)

Update the gridspec with arbitrary initialization keyword arguments and update the subplot positions.