rsatoolbox.vis.rdm_plot module

Plot showing an RDMs object

rsatoolbox.vis.rdm_plot.add_descriptor_x_labels(rdm: rsatoolbox.rdm.RDMs, pattern_descriptor: str, ax: Axes = None, num_pattern_groups: int = None, icon_spacing: float = 1.0, linewidth: float = 0.5) list[source]

add_descriptor_x_labels. Add labels to the X axis in ax by accessing the rdm.pattern_descriptors dict with the pattern_descriptor key.

Parameters:
  • rdm (rsatoolbox.rdm.RDMs) – RDMs instance to annotate.

  • pattern_descriptor (str) – dict key for the rdm.pattern_descriptors dict.

  • ax (matplotlib.axes._axes.Axes) – Matplotlib axis handle. plt.gca() by default.

  • num_pattern_groups (int) – Number of rows/columns for any image labels.

  • icon_spacing (float) – control spacing of image labels - 1. means no gap (the default), 1.1 means pad 10%, .9 means overlap 10% etc.

  • linewidth (float) – Width of connecting lines from icon labels (if used) to axis margin. The default is 0.5 - set to 0. to disable the lines.

Returns:

Tick label handles.

Return type:

list

rsatoolbox.vis.rdm_plot.add_descriptor_y_labels(rdm: rsatoolbox.rdm.RDMs, pattern_descriptor: str, ax: Axes = None, num_pattern_groups: int = None, icon_spacing: float = 1.0, linewidth: float = 0.5) list[source]

add_descriptor_y_labels. Add labels to the Y axis in ax by accessing the rdm.pattern_descriptors dict with the pattern_descriptor key.

Parameters:
  • rdm (rsatoolbox.rdm.RDMs) – RDMs instance to annotate.

  • pattern_descriptor (str) – dict key for the rdm.pattern_descriptors dict.

  • ax (matplotlib.axes._axes.Axes) – Matplotlib axis handle. plt.gca() by default.

  • num_pattern_groups (int) – Number of rows/columns for any image labels.

  • icon_spacing (float) – control spacing of image labels - 1. means no gap (the default), 1.1 means pad 10%, .9 means overlap 10% etc.

  • linewidth (float) – Width of connecting lines from icon labels (if used) to axis margin. The default is 0.5 - set to 0. to disable the lines.

Returns:

Tick label handles.

Return type:

list

rsatoolbox.vis.rdm_plot.show_rdm(rdm: rsatoolbox.rdm.RDMs, pattern_descriptor: str = None, cmap: str | Colormap = 'bone', rdm_descriptor: str = None, n_column: int = None, n_row: int = None, show_colorbar: str = None, gridlines: npt.ArrayLike = None, num_pattern_groups: int = None, figsize: Tuple[float, float] = None, nanmask: npt.ArrayLike = None, style: str | pathlib.Path = '/home/docs/checkouts/readthedocs.org/user_builds/rsatoolbox/envs/latest/lib/python3.8/site-packages/rsatoolbox/vis/rdm.mplstyle', vmin: float = None, vmax: float = None, icon_spacing: float = 1.0, linewidth: float = 0.5) Tuple[matplotlib.figure.Figure, npt.ArrayLike, collections.defaultdict][source]

show_rdm. Heatmap figure for RDMs instance, with one panel per RDM.

Parameters:
  • rdm (rsatoolbox.rdm.RDMs) – RDMs object to be plotted.

  • pattern_descriptor (str) – Key into rdm.pattern_descriptors to use for axis labels.

  • cmap (str or Colormap) – Colormap to be used. Either the name of a Matplotlib built-in colormap, a Matplotlib Colormap compatible object, or ‘classic’ for the matlab toolbox colormap. Defaults to ‘bone’.

  • rdm_descriptor (str) – Key for rdm_descriptor to use as panel title, or str for direct labeling.

  • n_column (int) – Number of columns in subplot arrangement.

  • n_row (int) – Number of rows in subplot arrangement.

  • show_colorbar (str) – Set to ‘panel’ or ‘figure’ to display a colorbar. If ‘panel’ a colorbar is added next to each RDM. If ‘figure’ a shared colorbar (and scale) is used across panels.

  • gridlines (npt.ArrayLike) – Set to add gridlines at these positions. If num_pattern_groups is defined this is used to infer gridlines.

  • num_pattern_groups (int) – Number of rows/columns for any image labels. Also determines gridlines frequency by default (so e.g., num_pattern_groups=3 with results in gridlines every 3 rows/columns).

  • figsize (Tuple[float, float]) – mpl.Figure argument. By default we auto-scale to achieve a figure that fits on a standard A4 / US Letter page in portrait orientation.

  • nanmask (npt.ArrayLike) – boolean mask defining RDM elements to suppress (by default, the diagonals).

  • style (Union[str, pathlib.Path]) – Path to mplstyle file that controls various figure aesthetics (default rsatoolbox/vis/rdm.mplstyle).

  • vmin (float) – Minimum intensity for colorbar mapping. matplotlib imshow argument.

  • vmax (float) – Maximum intensity for colorbar mapping. matplotlib imshow argument.

  • icon_spacing (float) – control spacing of image labels - 1. means no gap (the default), 1.1 means pad 10%, .9 means overlap 10% etc.

  • linewidth (float) – Width of connecting lines from icon labels (if used) to axis margin. The default is 0.5 - set to 0. to disable the lines.

Returns:

Tuple of

  • Handle to created figure.

  • Subplot axis handles from plt.subplots.

  • Nested dict containing handles to all other plotted objects (icon labels, colorbars, etc). The keys at the first level are the axis and figure handles.

Return type:

Tuple[matplotlib.figure.Figure, npt.ArrayLike, collections.defaultdict]

rsatoolbox.vis.rdm_plot.show_rdm_panel(rdm: rsatoolbox.rdm.RDMs, ax: Axes | None = None, cmap: str | Colormap = 'bone', nanmask: npt.ArrayLike = None, rdm_descriptor: str = None, gridlines: npt.ArrayLike = None, vmin: float = None, vmax: float = None) matplotlib.image.AxesImage[source]

show_rdm_panel. Add RDM heatmap to the axis ax.

Parameters:
  • rdm (rsatoolbox.rdm.RDMs) – RDMs object to be plotted (n_rdm must be 1).

  • ax (matplotlib.axes._axes.Axes) – Matplotlib axis handle. plt.gca() by default.

  • cmap (str or Colormap) – Colormap to be used. Either the name of a Matplotlib built-in colormap, a Matplotlib Colormap compatible object, or ‘classic’ for the matlab toolbox colormap. Defaults to ‘bone’.

  • nanmask (npt.ArrayLike) – boolean mask defining RDM elements to suppress (by default, the diagonals).

  • rdm_descriptor (str) – Key for rdm_descriptor to use as panel title, or str for direct labeling.

  • gridlines (npt.ArrayLike) – Set to add gridlines at these positions.

  • vmin (float) – Minimum intensity for colorbar mapping. matplotlib imshow argument.

  • vmax (float) – Maximum intensity for colorbar mapping. matplotlib imshow argument.

Returns:

Matplotlib handle.

Return type:

matplotlib.image.AxesImage