Module plottools.align

Align axes labels.

Upon importing this module, x- and y-labels are aligned automatically. Call align_params() turn off this behavior and to choose matplotlib's original functions instead of the ones provided by this module.

Figure member functions

Settings

Additional matplotlib.rcParams defined by the align module:

align.autox : True 
align.autoy : True 
align.overwritex : True 
align.overwritey : True 

Install/uninstall align functions

You usually do not need to call the install_align() function. Upon loading the align module, install_align() is called automatically.

  • install_align(): install code for aligning axes labels into show() and savefig() functions.
  • uninstall_align(): uninstall code for aligning axes labels in show() and savefig() functions.

Functions

def get_ticklabel_extend(axis, pos, height, renderer)
def align_xlabels(fig, axs=None)

Align xlabels of a figure.

Labels with the same orientation and on axes with the same coordinate are aligned to the bottommost one. In contrast to the matplotlib function with the same name, this functions aligns all labels, independently of any grids.

Parameters

fig : matplotlib figure
The figure on which xlabels and ylabels of all axes are aligned.
axs : list of matplotlib axes
Axes of which labels should be aligned. If None align labels of all axes.
def align_ylabels(fig, axs=None)

Align ylabels of a figure.

Labels with the same orientation and on axes with the same coordinate are aligned to the outmost one. In contrast to the matplotlib function with the same name, this functions aligns all labels, independently of any grids.

Parameters

fig : matplotlib figure
The figure on which xlabels and ylabels of all axes are aligned.
axs : list of matplotlib axes
Axes of which labels should be aligned. If None align labels of all axes.
def align_labels(fig, axs=None)

Align x- and ylabels of a figure.

Labels with the same orientation and on axes with the same coordinate are aligned to the outmost one. In contrast to the matplotlib function with the same name, this functions aligns all labels, independently of any grids.

Parameters

fig : matplotlib figure
The figure on which xlabels and ylabels of all axes are aligned.
axs : list of matplotlib axes
Axes of which labels should be aligned. If None align labels of all axes.
def set_align(fig, autox=None, autoy='same', overwritex=None, overwritey='same')

Modify align behavior of figure.

Only parameters that are not None are updated.

Parameters

autox : bool
If True then align_xlabels() is called automatically before showing or saving the figure.
autoy : bool or 'same'
If True then align_ylabels() is called automatically before showing or saving the figure. If 'same' use same argument as provided for autox.
overwritex : bool
If True, this module's align_xlabels() function is used instead of the respective function provided by matplotlib.
overwritey : bool or 'same'
If True, this module's align_ylabels() function is used instead of the respective function provided by matplotlib. If 'same' use same argument as provided for overwritex.
def align_params(autox=None, autoy='same', overwritex=None, overwritey='same')

Set global align parameters.

Only parameters that are not None are updated.

Parameters

autox : bool
If True then align_xlabels() is called automatically before showing or saving the figure. Sets rcParam align.autox.
autoy : bool or 'same'
If True then align_ylabels() is called automatically before showing or saving the figure. If 'same' use same argument as provided for autox. Sets rcParam align.autoy.
overwritex : bool
If True, this module's align_xlabels() function is used instead of the respective function provided by matplotlib. Sets rcParam align.overwritex.
overwritey : bool or 'same'
If True, this module's align_ylabels() function is used instead of the respective function provided by matplotlib. If 'same' use same argument as provided for overwritex. Sets rcParam align.overwritey.
def install_align()

Install code for aligning axes labels into show() and savefig() functions.

Adds matplotlib.rcParams:

align.autox : True 
align.autoy : True 
align.overwritex : True 
align.overwritey : True 

This function is called automatically upon importing the module.

See Also

uninstall_align()

def uninstall_align()

Uninstall code for aligning axes labels in show() and savefig() functions.

See Also

install_align_labels(), uninstall_labels()

def demo()

Run a demonstration of the align module.