matplotlib

Previous topic

mpl_toolkits.axes_grid.axes_size

Next topic

mpl_toolkits.axes_grid.axes_grid

This Page

mpl_toolkits.axes_grid.axes_divider

class mpl_toolkits.axes_grid.axes_divider.Divider(fig, pos, horizontal, vertical, aspect=None, anchor=u'C')

This is the class that is used calculates the axes position. It divides the given rectangular area into several sub-rectangles. You initialize the divider by setting the horizontal and vertical lists of sizes (mpl_toolkits.axes_grid.axes_size) that the division will be based on. You then use the new_locator method to create a callable object that can be used as the axes_locator of the axes.

Parameters:
  • fig – matplotlib figure
  • pos – position (tuple of 4 floats) of the rectangle that will be divided.
  • horizontal – list of sizes (axes_size) for horizontal division
  • vertical – list of sizes (axes_size) for vertical division
  • aspect – if True, the overall rectangular area is reduced so that the relative part of the horizontal and vertical scales have the same scale.
  • anchor – Determine how the reduced rectangle is placed when aspect is True.
add_auto_adjustable_area(use_axes, pad=0.1, adjust_dirs=None)
append_size(position, size)
get_anchor()

return the anchor

get_aspect()

return aspect

get_horizontal()

return horizontal sizes

get_horizontal_sizes(renderer)
get_locator()
get_position()

return the position of the rectangle.

get_position_runtime(ax, renderer)
get_vertical()

return vertical sizes

get_vertical_sizes(renderer)
get_vsize_hsize()
locate(nx, ny, nx1=None, ny1=None, axes=None, renderer=None)
Parameters:
  • nx1 (nx,) – Integers specifying the column-position of the cell. When nx1 is None, a single nx-th column is specified. Otherwise location of columns spanning between nx to nx1 (but excluding nx1-th column) is specified.
  • ny1 (ny,) – same as nx and nx1, but for row positions.
new_locator(nx, ny, nx1=None, ny1=None)

returns a new locator (mpl_toolkits.axes_grid.axes_divider.AxesLocator) for specified cell.

Parameters:
  • nx1 (nx,) – Integers specifying the column-position of the cell. When nx1 is None, a single nx-th column is specified. Otherwise location of columns spanning between nx to nx1 (but excluding nx1-th column) is specified.
  • ny1 (ny,) – same as nx and nx1, but for row positions.
set_anchor(anchor)
Parameters:anchor

anchor position

value description
‘C’ Center
‘SW’ bottom left
‘S’ bottom
‘SE’ bottom right
‘E’ right
‘NE’ top right
‘N’ top
‘NW’ top left
‘W’ left
set_aspect(aspect=False)
Parameters:anchor – True or False
set_horizontal(h)
Parameters:horizontal – list of sizes (axes_size) for horizontal division

.

set_locator(_locator)
set_position(pos)

set the position of the rectangle.

Parameters:pos – position (tuple of 4 floats) of the rectangle that will be divided.
set_vertical(v)
Parameters:horizontal – list of sizes (axes_size) for horizontal division

.

class mpl_toolkits.axes_grid.axes_divider.AxesLocator(axes_divider, nx, ny, nx1=None, ny1=None)

A simple callable object, initialized with AxesDivider class, returns the position and size of the given cell.

Parameters:
  • axes_divider – An instance of AxesDivider class.
  • nx1 (nx,) – Integers specifying the column-position of the cell. When nx1 is None, a single nx-th column is specified. Otherwise location of columns spanning between nx to nx1 (but excluding nx1-th column) is is specified.
  • ny1 (ny,) – same as nx and nx1, but for row positions.
get_subplotspec()
class mpl_toolkits.axes_grid.axes_divider.SubplotDivider(fig, *args, **kwargs)

The Divider class whose rectangle area is specified as a subplot geometry.

fig is a matplotlib.figure.Figure instance.

args is the tuple (numRows, numCols, plotNum), where the array of subplots in the figure has dimensions numRows, numCols, and where plotNum is the number of the subplot being created. plotNum starts at 1 in the upper left corner and increases to the right.

If numRows <= numCols <= plotNum < 10, args can be the decimal integer numRows * 100 + numCols * 10 + plotNum.

change_geometry(numrows, numcols, num)

change subplot geometry, e.g., from 1,1,1 to 2,2,3

get_geometry()

get the subplot geometry, e.g., 2,2,3

get_position()

return the bounds of the subplot box

get_subplotspec()

get the SubplotSpec instance

set_subplotspec(subplotspec)

set the SubplotSpec instance

update_params()

update the subplot position from fig.subplotpars

class mpl_toolkits.axes_grid.axes_divider.AxesDivider(axes, xref=None, yref=None)

Divider based on the pre-existing axes.

Parameters:axes – axes
append_axes(position, size, pad=None, add_to_figure=True, **kwargs)

create an axes at the given position with the same height (or width) of the main axes.

position
[“left”|”right”|”bottom”|”top”]

size and pad should be axes_grid.axes_size compatible.

new_horizontal(size, pad=None, pack_start=False, **kwargs)

Add a new axes on the right (or left) side of the main axes.

Parameters:
  • size – A width of the axes. A axes_size instance or if float or string is given, from_any function is used to create one, with ref_size set to AxesX instance of the current axes.
  • pad – pad between the axes. It takes same argument as size.
  • pack_start – If False, the new axes is appended at the end of the list, i.e., it became the right-most axes. If True, it is inserted at the start of the list, and becomes the left-most axes.

All extra keywords arguments are passed to the created axes. If axes_class is given, the new axes will be created as an instance of the given class. Otherwise, the same class of the main axes will be used.

new_vertical(size, pad=None, pack_start=False, **kwargs)

Add a new axes on the top (or bottom) side of the main axes.

Parameters:
  • size – A height of the axes. A axes_size instance or if float or string is given, from_any function is used to create one, with ref_size set to AxesX instance of the current axes.
  • pad – pad between the axes. It takes same argument as size.
  • pack_start – If False, the new axes is appended at the end of the list, i.e., it became the top-most axes. If True, it is inserted at the start of the list, and becomes the bottom-most axes.

All extra keywords arguments are passed to the created axes. If axes_class is given, the new axes will be created as an instance of the given class. Otherwise, the same class of the main axes will be used.