Version 3.1.2
matplotlib
Fork me on GitHub

mpl_toolkits.axes_grid1.axes_grid.Grid

class mpl_toolkits.axes_grid1.axes_grid.Grid(fig, rect, nrows_ncols, ngrids=None, direction='row', axes_pad=0.02, add_all=True, share_all=False, share_x=True, share_y=True, label_mode='L', axes_class=None)[source]

Bases: object

A class that creates a grid of Axes. In matplotlib, the axes location (and size) is specified in the normalized figure coordinates. This may not be ideal for images that needs to be displayed with a given aspect ratio. For example, displaying images of a same size with some fixed padding between them cannot be easily done in matplotlib. AxesGrid is used in such case.

Parameters:
fig : Figure

The parent figure.

rect : (float, float, float, float) or int

The axes position, as a (left, bottom, width, height) tuple or as a three-digit subplot position code (e.g., "121").

direction : {"row", "column"}, default: "row"
axes_pad : float or (float, float), default: 0.02

Padding or (horizontal padding, vertical padding) between axes, in inches.

add_all : bool, default: True
share_all : bool, default: False
share_x : bool, default: True
share_y : bool, default: True
label_mode : {"L", "1", "all"}, default: "L"

Determines which axes will get tick labels:

  • "L": All axes on the left column get vertical tick labels; all axes on the bottom row get horizontal tick labels.
  • "1": Only the bottom left axes is labelled.
  • "all": all axes are labelled.
axes_class : a type that is a subclass of matplotlib.axes.Axes, default: None
get_aspect(self)[source]

Return the aspect of the SubplotDivider.

get_axes_locator(self)[source]
get_axes_pad(self)[source]

Return the axes padding.

Returns:
hpad, vpad

Padding (horizontal pad, vertical pad) in inches.

get_divider(self)[source]
get_geometry(self)[source]

Return the number of rows and columns of the grid as (nrows, ncols).

get_vsize_hsize(self)[source]
set_aspect(self, aspect)[source]

Set the aspect of the SubplotDivider.

set_axes_locator(self, locator)[source]
set_axes_pad(self, axes_pad)[source]

Set the padding between the axes.

Parameters:
axes_pad : (float, float)

The padding (horizontal pad, vertical pad) in inches.

set_label_mode(self, mode)[source]

Define which axes have tick labels.

Parameters:
mode : {"L", "1", "all"}

The label mode:

  • "L": All axes on the left column get vertical tick labels; all axes on the bottom row get horizontal tick labels.
  • "1": Only the bottom left axes is labelled.
  • "all": all axes are labelled.