Module: layout

mpltools.layout.clear_frame([ax]) Remove the frame (ticks and spines) from an axes.
mpltools.layout.clip_zero_formatter(...) Tick formatter that returns empty string for zero values.
mpltools.layout.cross_spines([zero_cross, ...]) Remove top and right spines from an axes.
mpltools.layout.figaspect([aspect_ratio, ...]) Return figure size (width, height) in inches.
mpltools.layout.figimage(img[, scale, dpi]) Return figure and axes with figure tightly surrounding image.
mpltools.layout.figure([aspect_ratio, ...]) Return matplotlib figure window.
mpltools.layout.pad_limits([pad_frac, ax]) Pad data limits to nicely accomodate data.

clear_frame

mpltools.layout.clear_frame(ax=None)[source]

Remove the frame (ticks and spines) from an axes.

This differs from turning off the axis (plt.axis(‘off’) or ax.set_axis_off()) in that only the ticks and spines are removed. Turning off the axis also removes the axes background and axis labels.

Parameters :

ax : Axes

Axes to modify. If None, use current axes.

clip_zero_formatter

mpltools.layout.clip_zero_formatter(tick_val, tick_pos)

Tick formatter that returns empty string for zero values.

cross_spines

mpltools.layout.cross_spines(zero_cross=False, remove_zeros=True, ax=None)[source]

Remove top and right spines from an axes.

Parameters :

zero_cross : bool

If True, the spines are set so that they cross at zero.

remove_zeros : bool

If True and `zero_cross` is True, remove zero ticks.

ax : Axes

Axes to modify. If None, use current axes.

figaspect

mpltools.layout.figaspect(aspect_ratio=0.75, scale=1, width=None)[source]

Return figure size (width, height) in inches.

Calculate figure height using aspect_ratio and default figure width. For example, figaspect(2) gives a size that’s twice as tall as it is wide.

Note that figaspect uses the default figure width, or a specified width, and adjusts the height; this is the opposite of pyplot.figaspect, which constrains the figure height and adjusts the width. This function’s behavior is preferred when you have a constraint on the figure width (e.g. in a journal article or a web page with a set body-width).

Parameters :

aspect_ratio : float

Aspect ratio, height / width, of figure.

scale : float

Scale default size of the figure.

width : float

Figure width in inches. If None, default to rc parameters.

Returns :

width, height : float

Width and height of figure.

figimage

mpltools.layout.figimage(img, scale=1, dpi=None)[source]

Return figure and axes with figure tightly surrounding image.

Unlike pyplot.figimage, this actually plots onto an axes object, which fills the figure. Plotting the image onto an axes allows for subsequent overlays.

Parameters :

img : array

image to plot

scale : float

If scale is 1, the figure and axes have the same dimension as the image. Smaller values of scale will shrink the figure.

dpi : int

Dots per inch for figure. If None, use the default rcParam.

figure

mpltools.layout.figure(aspect_ratio=0.75, scale=1, width=None, **kwargs)[source]

Return matplotlib figure window.

Calculate figure height using aspect_ratio and default figure width.

Parameters :

aspect_ratio : float

Aspect ratio, height / width, of figure.

scale : float

Scale default size of the figure.

width : float

Figure width in inches. If None, default to rc parameters.

See also

figaspect

pad_limits

mpltools.layout.pad_limits(pad_frac=0.050000000000000003, ax=None)[source]

Pad data limits to nicely accomodate data.

Padding is useful when you use markers, which often get cropped by tight data limits since only their center-positions are used to calculate limits.

Parameters :

pad_frac : float

Padding is calculated as a fraction of the data span. pad_frac = 0 is equivalent to calling plt.axis(‘tight’).

ax : Axes

Axes to modify. If None, use current axes.

Table Of Contents

Previous topic

Module: io

Next topic

Module: special