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_matrix

nilearn.plotting.plot_matrix(mat, title=None, labels=None, figure=None, axes=None, colorbar=True, cmap=<matplotlib.colors.LinearSegmentedColormap object>, tri='full', auto_fit=True, grid=False, reorder=False, **kwargs)

Plot the given matrix.


mat : 2-D numpy array

Matrix to be plotted.

title : string or None, optional

A text to add in the upper left corner.

labels : list of strings, optional

The label of each row and column

figure : figure instance, figsize tuple, or None

Sets the figure used. This argument can be either an existing figure, or a pair (width, height) that gives the size of a newly-created figure. Specifying both axes and figure is not allowed.

axes : None or Axes, optional

Axes instance to be plotted on. Creates a new one if None. Specifying both axes and figure is not allowed.

colorbar : boolean, optional

If True, an integrated colorbar is added.

cmap : matplotlib colormap, optional

The colormap for the matrix. Default is RdBu_r.

tri : {‘lower’, ‘diag’, ‘full’}, optional

Which triangular part of the matrix to plot: ‘lower’ is the lower part, ‘diag’ is the lower including diagonal, and ‘full’ is the full matrix.

auto_fit : boolean, optional

If auto_fit is True, the axes are dimensioned to give room for the labels. This assumes that the labels are resting against the bottom and left edges of the figure.

grid : color or False, optional

If not False, a grid is plotted to separate rows and columns using the given color.

reorder : boolean or {‘single’, ‘complete’, ‘average’}, optional

If not False, reorders the matrix into blocks of clusters. Accepted linkage options for the clustering are ‘single’, ‘complete’, and ‘average’. True defaults to average linkage.


This option is only available with SciPy >= 1.0.0.

New in version 0.4.1.

kwargs : extra keyword arguments

Extra keyword arguments are sent to pylab.imshow


display : instance of matplotlib

Axes image.