This page is a reference documentation. It only explains the class signature, and not how to use it. Please refer to the user guide for the big picture.


class nilearn.plotting.displays.CutAxes(ax, direction, coord, radiological=False)[source]#

An MPL axis-like object that displays a cut of 3D volumes.


The matplotlib axes in which the plots will be drawn.

direction{‘x’, ‘y’, ‘z’}

The directions of the view.


The coordinate along the direction of the cut.

__init__(ax, direction, coord, radiological=False)[source]#
transform_to_2d(data, affine)[source]#

Cut the 3D volume into a 2D slice.

data3D ndarray

The 3D volume to cut.

affine4x4 ndarray

The affine of the volume.

draw_position(size, bg_color, decimals=False, **kwargs)[source]#

Draw coordinates.

sizefloat, optional

Size of the text area.

bg_colormatplotlib color: str or (r, g, b) value

The background color for text area.

decimalsbool or str, default=False

Formatting string for the coordinates. If set to False, integer formatting will be used.


Ensure that axes get rescaled when adding object bounds.

draw_2d(data_2d, data_bounds, bounding_box, type='imshow', **kwargs)[source]#

Draw 2D.

draw_left_right(size, bg_color, **kwargs)[source]#

Draw the annotation “L” for left, and “R” for right.

sizefloat, optional

Size of the text areas.

bg_colormatplotlib color: str or (r, g, b) value

The background color for both text areas.

draw_scale_bar(bg_color, size=5.0, units='cm', fontproperties=None, frameon=False, loc=4, pad=0.1, borderpad=0.5, sep=5, size_vertical=0, label_top=False, color='black', fontsize=None, **kwargs)[source]#

Add a scale bar annotation to the display.

bg_colormatplotlib color: str or (r, g, b) value

The background color of the scale bar annotation.

sizefloat, default=5.0

Horizontal length of the scale bar, given in units.

unitsstr, default=’cm’

Physical units of the scale bar (‘cm’ or ‘mm’).

fontpropertiesFontProperties or dict, optional

Font properties for the label text.

frameonbool, default=False

Whether the scale bar is plotted with a border.

locint, default=4

Location of this scale bar. Valid location codes are documented here.

padint or float, default=0.1

Padding around the label and scale bar, in fraction of the font size.

borderpadint or float, default=0.5

Border padding, in fraction of the font size.

sepint or float, default=5

Separation between the label and the scale bar, in points.

size_verticalint or float, default=0

Vertical length of the size bar, given in units.

label_topbool, default=False

If True, the label will be over the scale bar.

colorstr, default=’black’

Color for the scale bar and label.

fontsizeint, optional

Label font size (overwrites the size passed in through the fontproperties argument).


Keyworded arguments to pass to AnchoredOffsetbox.


Return the bounds of the objects on this axes.