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
align_xlabels()
: align xlabels of a figure.align_ylabels()
: align ylabels of a figure.align_labels()
: align x- and ylabels of a figure.set_align()
: modify align behavior of figure.
Settings
align_params()
: set global align parameters.
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 intoshow()
andsavefig()
functions.uninstall_align()
: uninstall code for aligning axes labels inshow()
andsavefig()
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
ofmatplotlib 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
ofmatplotlib 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
ofmatplotlib 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
thenalign_xlabels()
is called automatically before showing or saving the figure. autoy
:bool
or'same'
- If
True
thenalign_ylabels()
is called automatically before showing or saving the figure. If 'same' use same argument as provided forautox
. overwritex
:bool
- If
True
, this module'salign_xlabels()
function is used instead of the respective function provided by matplotlib. overwritey
:bool
or'same'
- If
True
, this module'salign_ylabels()
function is used instead of the respective function provided by matplotlib. If 'same' use same argument as provided foroverwritex
.
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
thenalign_xlabels()
is called automatically before showing or saving the figure. Sets rcParamalign.autox
. autoy
:bool
or'same'
- If
True
thenalign_ylabels()
is called automatically before showing or saving the figure. If 'same' use same argument as provided forautox
. Sets rcParamalign.autoy
. overwritex
:bool
- If
True
, this module'salign_xlabels()
function is used instead of the respective function provided by matplotlib. Sets rcParamalign.overwritex
. overwritey
:bool
or'same'
- If
True
, this module'salign_ylabels()
function is used instead of the respective function provided by matplotlib. If 'same' use same argument as provided foroverwritex
. Sets rcParamalign.overwritey
.
def install_align()
-
Install code for aligning axes labels into
show()
andsavefig()
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
def uninstall_align()
-
Uninstall code for aligning axes labels in
show()
andsavefig()
functions.See Also
install_align_labels()
,uninstall_labels()
def demo()
-
Run a demonstration of the align module.