tp.axes package

Module contents

Provides pre-sized axes.

The name convention is tp.axes.[size].[number](_[description]), where decription starts with a shape if the number is greater than one, and lists the additional things (dos, colourbar) from left to right. The small style is based somewhat on the Nature guidelines (we can all dream!), where the axes.small.one figure has a width of 8.6 cm. All axes are square, and subsequent figures maintain the height of axes.one per plot (single height plots have a height of 8.3 cm whilst double height plots have a height of 16.6 cm, which more effectively maintains relative scale, as colourbars etc. are normally added on the side). As per the guidelines, font size is 8 pt. The large style uses larger axes and relatively even larger fonts, which is better suited for presentations, posters and non-columnated text. legend is for legend handling, which is primarily used internally but may be useful if you make your own axes from scratch.

Submodules

tp.axes.small module

Provides pre-sized figures for paper-sized figures.

Each function returns a figure, a set of axes or an array of sets of axes and an add_legend function. The legend function comes with a choice of positions and takes normal ax.legend arguments.

tp.axes.small.four_square(style=[])[source]

A figure with four sets of axes in a square.

Parameters

style (str or array, optional) – style sheet(s). Default: tp.

Returns

  • figure – figure.

  • list – axes.

  • function – function to add a pre-positioned legend.

tp.axes.small.four_square_colourbars(style=[])[source]

A figure with four sets of axes with colourbars in a square.

Parameters

style (str or array, optional) – style sheet(s). Default: tp.

Returns

  • figure – figure.

  • list – axes.

  • function – function to add a pre-positioned legend.

tp.axes.small.one(style=[])[source]

A figure with a set of axes.

Parameters

style (str or array, optional) – style sheet(s). Default: tp.

Returns

  • figure – figure.

  • axes – axes.

  • function – function to add a pre-positioned legend.

tp.axes.small.one_colourbar(style=[])[source]

A figure with a set of axes and colourbar space.

Parameters

style (str or array, optional) – style sheet(s). Default: tp.

Returns

  • figure – figure.

  • axes – axes.

  • function – function to add a pre-positioned legend.

tp.axes.small.one_dos(style=[])[source]

A figure with a set of axes and a DoS-style attachment.

Parameters

style (str or array, optional) – style sheet(s). Default: tp.

Returns

  • figure – figure.

  • axes – axes.

  • function – function to add a pre-positioned legend.

tp.axes.small.one_dos_colourbar(style=[])[source]

A figure with axes, DoS-style attachment and colourbar space.

Parameters

style (str or array, optional) – style sheet(s). Default: tp.

Returns

  • figure – figure.

  • axes – axes.

  • function – function to add a pre-positioned legend.

tp.axes.small.three_h(style=[])[source]

A figure with three sets of axes horizontally.

Parameters

style (str or array, optional) – style sheet(s). Default: tp.

Returns

  • figure – figure.

  • axes – axes.

  • function – function to add a pre-positioned legend.

tp.axes.small.three_h_colourbars(style=[])[source]

A figure with three sets of axes horizontally and colourbars.

Parameters

style (str or array, optional) – style sheet(s). Default: tp.

Returns

  • figure – figure.

  • axes – axes.

  • function – function to add a pre-positioned legend.

tp.axes.small.three_square(style=[], blank=2)[source]

Axes in a square with one missing.

The legend is placed in the blank space by default.

Parameters
  • style (str or array, optional) – style sheet(s). Default: tp.

  • blank (int, optional) – empty quadrant (numbered left to right then top to bottom).

Returns

  • figure – figure.

  • list – axes.

  • function – function to add a pre-positioned legend.

tp.axes.small.three_square_colourbars(style=[], blank=2)[source]

Axes with colourbars in a square with one missing.

The legend is placed in the blank space by default.

Parameters
  • style (str or array, optional) – style sheet(s). Default: tp.

  • blank (int, optional) – empty quadrant (numbered left to right then top to bottom).

Returns

  • figure – figure.

  • list – axes.

  • function – function to add a pre-positioned legend.

tp.axes.small.two_h(style=[])[source]

A figure with two sets of axes horizontally.

Parameters

style (str or array, optional) – style sheet(s). Default: tp.

Returns

  • figure – figure.

  • axes – axes.

  • function – function to add a pre-positioned legend.

tp.axes.small.two_h_colourbars(style=[])[source]

A figure with two sets of axes horizontally with colourbars.

Parameters

style (str or array, optional) – style sheet(s). Default: tp.

Returns

  • figure – figure.

  • axes – axes.

  • function – function to add a pre-positioned legend.

tp.axes.small.two_v(style=[])[source]

A figure with two sets of axes vertically.

Parameters

style (str or array, optional) – style sheet(s). Default: tp.

Returns

  • figure – figure.

  • axes – axes.

  • function – function to add a pre-positioned legend.

tp.axes.small.two_v_colourbars(style=[])[source]

A figure with two sets of axes vertically with colourbars.

Parameters

style (str or array, optional) – style sheet(s). Default: tp.

Returns

  • figure – figure.

  • axes – axes.

  • function – function to add a pre-positioned legend.

tp.axes.large module

Provides pre-sized figures for presentation-sized figures.

Each function returns a figure, a set of axes or an array of sets of axes and an add_legend function. The legend function comes with a choice of positions and takes normal ax.legend arguments. Drawing large figures is significantly slower than small ones.

tp.axes.large.four_square(style=[])[source]

A figure with four sets of axes in a square.

Parameters

style (str or array, optional) – style sheet(s). Default: tp.

Returns

  • figure – figure.

  • list – axes.

  • function – function to add a pre-positioned legend.

tp.axes.large.four_square_colourbars(style=[])[source]

A figure with four sets of axes with colourbars in a square.

Parameters

style (str or array, optional) – style sheet(s). Default: tp.

Returns

  • figure – figure.

  • list – axes.

  • function – function to add a pre-positioned legend.

tp.axes.large.one(style=[])[source]

A figure with a set of axes.

Parameters

style (str or array, optional) – style sheet(s). Default: tp.

Returns

  • figure – figure.

  • axes – axes.

  • function – function to add a pre-positioned legend.

tp.axes.large.one_colourbar(style=[])[source]

A figure with a set of axes and colourbar space.

Parameters

style (str or array, optional) – style sheet(s). Default: tp.

Returns

  • figure – figure.

  • axes – axes.

  • function – function to add a pre-positioned legend.

tp.axes.large.one_dos(style=[])[source]

A figure with a set of axes and a DoS-style attachment.

Parameters

style (str or array, optional) – style sheet(s). Default: tp.

Returns

  • figure – figure.

  • axes – axes.

  • function – function to add a pre-positioned legend.

tp.axes.large.one_dos_colourbar(style=[])[source]

A figure with axes, DoS-style attachment and colourbar space.

Parameters

style (str or array, optional) – style sheet(s). Default: tp.

Returns

  • figure – figure.

  • axes – axes.

  • function – function to add a pre-positioned legend.

tp.axes.large.three_h(style=[])[source]

A figure with three sets of axes horizontally.

Parameters

style (str or array, optional) – style sheet(s). Default: tp.

Returns

  • figure – figure.

  • axes – axes.

  • function – function to add a pre-positioned legend.

tp.axes.large.three_h_colourbars(style=[])[source]

A figure with three sets of axes horizontally and colourbars.

Parameters

style (str or array, optional) – style sheet(s). Default: tp.

Returns

  • figure – figure.

  • axes – axes.

  • function – function to add a pre-positioned legend.

tp.axes.large.three_square(style=[], blank=2)[source]

Axes in a square with one missing.

The legend is placed in the blank space by default.

Parameters
  • style (str or array, optional) – style sheet(s). Default: tp.

  • blank (int, optional) – empty quadrant (numbered left to right then top to bottom).

Returns

  • figure – figure.

  • list – axes.

  • function – function to add a pre-positioned legend.

tp.axes.large.three_square_colourbars(style=[], blank=2)[source]

Axes with colourbars in a square with one missing.

The legend is placed in the blank space by default.

Parameters
  • style (str or array, optional) – style sheet(s). Default: tp.

  • blank (int, optional) – empty quadrant (numbered left to right then top to bottom).

Returns

  • figure – figure.

  • list – axes.

  • function – function to add a pre-positioned legend.

tp.axes.large.two_h(style=[])[source]

A figure with two sets of axes horizontally.

Parameters

style (str or array, optional) – style sheet(s). Default: tp.

Returns

  • figure – figure.

  • axes – axes.

  • function – function to add a pre-positioned legend.

tp.axes.large.two_h_colourbars(style=[])[source]

A figure with two sets of axes horizontally with colourbars.

Parameters

style (str or array, optional) – style sheet(s). Default: tp.

Returns

  • figure – figure.

  • axes – axes.

  • function – function to add a pre-positioned legend.

tp.axes.large.two_v(style=[])[source]

A figure with two sets of axes vertically.

Parameters

style (str or array, optional) – style sheet(s). Default: tp.

Returns

  • figure – figure.

  • axes – axes.

  • function – function to add a pre-positioned legend.

tp.axes.large.two_v_colourbars(style=[])[source]

A figure with two sets of axes vertically with colourbars.

Parameters

style (str or array, optional) – style sheet(s). Default: tp.

Returns

  • figure – figure.

  • axes – axes.

  • function – function to add a pre-positioned legend.

tp.axes.legend module

Functions for dealing with legends.

tp.axes.legend.add_add_legend(ax, locations, names, defloc)[source]

Adds an add_legend function.

Parameters
  • ax (list or axes) – axes to add add_legend to.

  • locations (list of dicts) – outside-axes legend arguments (loc and bbox_to_anchor) and axes ordinal (e.g. ‘axes’: 0, if there is more than one) in a flat array in the order of the flattened axes array by row.

  • names (list of lists) – names of locations in an flat array in the order of the flattened axes array by row, with additional locations in order at the end. Ordinal integers added automatically.

  • defloc (str) – default location name.

Returns

add_legend.

Return type

function

tp.axes.legend.alphabetise(ax, labels=None, preset='latin', prefix='', suffix='', x=0.0, y=1.01, label_dos=True)[source]

Enumerates or alphabetises plot axes

Can manually define, or some presets are available.

Parameters
  • ax (axes or list) – axes to enumerate.

  • labels (str or list, optional) – manually defined labels. Overrides preset.

  • preset (str) –

    preset label sequence. Options:

    latin

    a, b, c… (default)

    Latin

    A, B, C…

    arabic

    1, 2, 3…

    roman

    i, ii, iii…

    Roman

    I, II, III…

    greek

    alpha, beta, gamma…

    Greek

    Alpha, Beta, Gamma…

  • prefix (str, optional) – prefix to all labels, e.g. “(“. Default: None.

  • suffix (str, optional) – suffix to all labels, e.g. “)”. Default: None.

  • x (float, optional) – x-position, where the axis is a scale from 0-1. Default: 0.

  • y (float, optional) – y-position, where the axis is a scale from 0-1. Default: 1.01.

  • label_dos (bool, optional) – label DoS axes. Only works with tp axes. Default: True.

tp.axes.legend.consolidate(axes)[source]

Combine legends.

Also removes duplicates.

Parameters

axes (array-like) – axes to combine the legends for.

Returns

  • array-like – legend handles.

  • array-like – legend labels.