Module plottools.labels

Annotate axis with label and unit.

Axes member functions

Settings

mpl.rcParams defined by the labels module:

axes.label.format: '{label} [{unit}]'
xaxis.labelrotation: 'horizontal'
yaxis.labelrotation: 'vertical'

Install/uninstall labels functions

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

Functions

def set_xlabel(ax, label, unit=None, **kwargs)

Format the xlabel from a label and an unit.

Uses the __axis_label() function to format the axis label.

Parameters

label : string
The name of the axis.
unit : string
The unit of the axis values.
kwargs : key-word arguments
Further arguments passed on to the set_xlabel() function.
def set_ylabel(ax, label, unit=None, **kwargs)

Format the ylabel from a label and an unit.

Uses the __axis_label() function to format the axis label.

Parameters

label : string
The name of the axis.
unit : string
The unit of the axis values.
kwargs : key-word arguments
Further arguments passed on to the set_ylabel() function.
def set_zlabel(ax, label, unit=None, **kwargs)

Format the zlabel from a label and an unit.

Uses the __axis_label() function to format the axis label.

Parameters

label : string
The name of the axis.
unit : string
The unit of the axis values.
kwargs : key-word arguments
Further arguments passed on to the set_zlabel() function.
def labels_params(labelformat=None, labelsize=None, labelweight=None, labelcolor='axes', labelpad=None, xlabelloc=None, ylabelloc=None, xlabelrot=None, ylabelrot=None)

Set parameters for axis labels.

Only parameters that are not None are updated.

Parameters

labelformat : string
Set the string specifying how axes labels are formatted. In this string '{label}' is replaced by the axes' label, and '{unit}' is replaced by the axes' unit. The default format string is '{label} [{unit}]'. Set rcParam axes.label.format.
labelsize : float or string
Set font size for x- and y-axis labels. Sets rcParam axes.labelsize.
labelweight : {'normal', 'bold', 'bolder', 'lighter'}
Set font weight for x- and y-axis labels. Sets rcParam axes.labelweight.
labelcolor : matplotlib color or 'axes'
Color of x- and y-axis labels. If 'axes' set to color of axes (rcParam axes.edgecolor). Sets rcParam axes.labelcolor.
labelpad : float
Set space between x- and y-axis labels and axis in points. Sets rcParam axes.labelpad.
xlabelloc : {'center', 'left', 'right'}
Location of xlabels. Sets rcParams xaxis.labellocation.
ylabelloc : {'center', 'bottom', 'top'}
Location of ylabels. Sets rcParams yaxis.labellocation.
xlabelrot : float, or {'horizontal', 'vertical'}
Rotation angle of xlabels. Sets rcParams xaxis.labelrotation.
ylabelrot : float, or {'horizontal', 'vertical'}
Rotation angle of ylabels. Sets rcParams yaxis.labelrotation.
def install_labels()

Install labels functions on matplotlib axes.

Adds matplotlib.rcParams:

axes.label.format: '{label} [{unit}]'
xaxis.labelrotation: 'horizontal'
yaxis.labelrotation: 'vertical'

This function is also called automatically upon importing the module.

See Also

set_xlabel(), uninstall_labels()

def uninstall_labels()

Uninstall labels functions from matplotlib axes.

Call this function to disable anything that was installed by install_labels().

See Also

install_labels()

def demo()

Run a demonstration of the labels module.