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

7.10.6. nilearn.plotting.plot_roi

nilearn.plotting.plot_roi(roi_img, bg_img=<MNI152Template>, cut_coords=None, output_file=None, display_mode=’ortho’, figure=None, axes=None, title=None, annotate=True, draw_cross=True, black_bg=’auto’, threshold=0.5, alpha=0.7, cmap=<matplotlib.colors.LinearSegmentedColormap object>, dim=’auto’, vmin=None, vmax=None, **kwargs)

Plot cuts of an ROI/mask image (by default 3 cuts: Frontal, Axial, and Lateral)


roi_img : Niimg-like object

See The ROI/mask image, it could be binary mask or an atlas or ROIs with integer values.

bg_img : Niimg-like object

See The background image that the ROI/mask will be plotted on top of. If nothing is specified, the MNI152 template will be used. To turn off background image, just pass “bg_img=None”.

cut_coords : None, or a tuple of floats

The MNI coordinates of the point where the cut is performed, in MNI coordinates and order. If display_mode is ‘ortho’, this should be a 3-tuple: (x, y, z) For display_mode == ‘x’, ‘y’, or ‘z’, then these are the coordinates of each cut in the corresponding direction. If None is given, the cuts is calculated automaticaly.

output_file : string, or None, optional

The name of an image file to export the plot to. Valid extensions are .png, .pdf, .svg. If output_file is not None, the plot is saved to a file, and the display is closed.

display_mode : {‘ortho’, ‘x’, ‘y’, ‘z’, ‘yx’, ‘xz’, ‘yz’}

Choose the direction of the cuts: ‘x’ - sagittal, ‘y’ - coronal, ‘z’ - axial, ‘ortho’ - three cuts are performed in orthogonal directions.

figure : integer or matplotlib figure, optional

Matplotlib figure used or its number. If None is given, a new figure is created.

axes : matplotlib axes or 4 tuple of float: (xmin, ymin, width, height), optional

The axes, or the coordinates, in matplotlib figure space, of the axes used to display the plot. If None, the complete figure is used.

title : string, optional

The title displayed on the figure.

annotate : boolean, optional

If annotate is True, positions and left/right annotation are added to the plot.

draw_cross : boolean, optional

If draw_cross is True, a cross is drawn on the plot to indicate the cut plosition.

black_bg : boolean, optional

If True, the background of the image is set to be black. If you wish to save figures with a black background, you will need to pass “facecolor=’k’, edgecolor=’k’” to matplotlib.pyplot.savefig.

threshold : None, ‘auto’, or a number (0.5 by default), optional

If None is given, the image is not thresholded. If a number is given, it is used to threshold the image: values below the threshold (in absolute value) are plotted as transparent. If auto is given, the threshold is determined magically by analysis of the image.

dim : float, ‘auto’ (by default), optional

Dimming factor applied to background image. By default, automatic heuristics are applied based upon the background image intensity. Accepted float values, where a typical span is -1 to 1 (-1 = increase contrast; 1 = decrease contrast), but larger values can be used for a more pronounced effect. 0 means no dimming.

vmin : float

Lower bound for plotting, passed to matplotlib.pyplot.imshow

vmax : float

Upper bound for plotting, passed to matplotlib.pyplot.imshow

See also

To simply plot probabilistic atlases (4D images)


A small threshold is applied by default to eliminate numerical background noise.

For visualization, non-finite values found in passed ‘roi_img’ or ‘bg_img’ are set to zero.