mpl.colorbar.make_axes_gridspec()

mpl.colorbar.make_axes_gridspec(parent, **kw)[source]

Resize and reposition a parent axes, and return a child axes suitable for a colorbar. This function is similar to make_axes. Prmary differences are

  • make_axes_gridspec only handles the orientation keyword and cannot handle the “location” keyword.

  • make_axes_gridspec should only be used with a subplot parent.

  • make_axes creates an instance of Axes. make_axes_gridspec

    creates an instance of Subplot.

  • make_axes updates the position of the

    parent. make_axes_gridspec replaces the grid_spec attribute of the parent with a new one.

While this function is meant to be compatible with make_axes, there could be some minor differences.:

cax, kw = make_axes_gridspec(parent, **kw)

Keyword arguments may include the following (with defaults):

orientation
‘vertical’ or ‘horizontal’
Property Description
orientation vertical or horizontal
fraction 0.15; fraction of original axes to use for colorbar
pad 0.05 if vertical, 0.15 if horizontal; fraction of original axes between colorbar and new image axes
shrink 1.0; fraction by which to shrink the colorbar
aspect 20; ratio of long to short dimensions
anchor (0.0, 0.5) if vertical; (0.5, 1.0) if horizontal; the anchor point of the colorbar axes
panchor (1.0, 0.5) if vertical; (0.5, 0.0) if horizontal; the anchor point of the colorbar parent axes. If False, the parent axes’ anchor will be unchanged

All but the first of these are stripped from the input kw set.

Returns (cax, kw), the child axes and the reduced kw dictionary to be passed when creating the colorbar instance.