rsatoolbox.vis.rdm_plot module

Plot showing an RDMs object

public API:

  • show_rdm()

  • show_rdm_panel()

class rsatoolbox.vis.rdm_plot.Axis(value)[source]

Bases: Enum

X or Y axis Enum

X = 'x'
Y = 'y'
class rsatoolbox.vis.rdm_plot.MultiRdmPlot(rdms: RDMs)[source]

Bases: object

Configuration for the multi-rdm plot

addContour(mask: ArrayOrRdmDescriptor, color: str, triangles: Symmetry)[source]
addOverlay(mask: ArrayOrRdmDescriptor, color: str, triangles: Symmetry)[source]
ax: NDArray | None
classmethod calc_figsize(n_column: int, n_row: int) Tuple[float, float][source]

” scale with number of RDMs, up to (intersection of A4 and us letter)

cmap: str | Colormap
contour: NDArray
contour_color: str
contour_mask: NDArray
contour_symmetry: Symmetry
classmethod determine_rows_cols_panels(n_row: int | None, n_column: int | None, n_panel: int) Tuple[int, int][source]

Choose the number of rows and columns of panels

dissimilarity_measure: str
fig: Figure | None
figsize: Tuple[float, float]
for_single(index: int) SingleRdmPlot[source]

Create a SingleRdmPlot object for the given rdm index

Parameters:

index (int) – Index for the rdms

Returns:

_description_

Return type:

SingleRdmPlot

classmethod from_show_rdm_args(rdm: RDMs, pattern_descriptor: str | None, cmap: str | Colormap, rdm_descriptor: str | None, n_column: int | None, n_row: int | None, show_colorbar: str | None, gridlines: ArrayLike | None, num_pattern_groups: int | None, figsize: Tuple[float, float] | None, nanmask: NDArray | str | None, style: str | Path | None, vmin: float | None, vmax: float | None, icon_spacing: float, linewidth: float, overlay: Tuple[str, str] | NDArray | None, overlay_color: str, overlay_symmetry: Symmetry, contour: Tuple[str, str] | NDArray | None, contour_color: str, contour_symmetry: Symmetry) MultiRdmPlot[source]

Create an object from the original arguments to show_rdm()

gridlines: NDArray
handles: Dict[int, Dict[str, Any]] | None
icon_spacing: float
classmethod init_nan_mask(nanmask: NDArray | str | None, rdms: RDMs) NDArray[source]

Interpret user’s choice of nanmask

interpret_rdm_arg(val: ArrayOrRdmDescriptor | None, rdms: RDMs) NDArray[source]

Resolve argument that can be an rdm descriptor key/value pair or a utv

linewidth: float
n_column: int
n_panel: int
n_row: int
nanmask: NDArray
num_pattern_groups: int
overlay: NDArray
overlay_color: str
overlay_mask: NDArray
overlay_symmetry: Symmetry
pattern_descriptor: str | None
plot()[source]
rdm_descriptor: str
rdms: RDMs
show_colorbar: Literal['panel'] | Literal['figure'] | None
style: Path
vmax: float | None
vmin: float | None
class rsatoolbox.vis.rdm_plot.SingleRdmPlot[source]

Bases: object

Configuration for the single-rdm plot

ax: NDArray | None
cmap: str | Colormap
contour: NDArray
contour_color: str
contour_mask: NDArray
contour_symmetry: Symmetry
fig: Figure | None
classmethod from_show_rdm_panel_args(rdms: RDMs, cmap: str | Colormap, nanmask: NDArray | None, rdm_descriptor: str | None, gridlines: ArrayLike | None, vmin: float | None, vmax: float | None, overlay: NDArray | None, overlay_color: str, overlay_symmetry: Symmetry, contour: NDArray | None, contour_color: str, contour_symmetry: Symmetry) SingleRdmPlot[source]

Create an object from the original arguments to show_rdm_panel()

gridlines: ArrayLike
handles: Dict[int, Dict[str, Any]] | None
interpret_rdm_arg(val: ArrayOrRdmDescriptor | None, rdms: RDMs) NDArray[source]

Resolve argument that can be an rdm descriptor key/value pair or a utv

nanmask: NDArray
overlay: NDArray
overlay_color: str
overlay_mask: NDArray
overlay_symmetry: Symmetry
rdm_descriptor: str
rdms: RDMs
title: str
vmax: float | None
vmin: float | None
class rsatoolbox.vis.rdm_plot.Symmetry(value)[source]

Bases: Enum

RDM Triangle Enum: both, upper or lower

BOTH = 'both'
LOWER = 'lower'
UPPER = 'upper'
rsatoolbox.vis.rdm_plot.show_rdm(rdms: rsatoolbox.rdm.RDMs, pattern_descriptor: str | None = None, cmap: str | Colormap = 'bone_r', rdm_descriptor: str | None = None, n_column: int | None = None, n_row: int | None = None, show_colorbar: str | None = None, gridlines: ArrayLike | None = None, num_pattern_groups: int | None = None, figsize: Tuple[float, float] | None = None, nanmask: NDArray | str | None = 'diagonal', style: str | Path | None = None, vmin: float | None = None, vmax: float | None = None, icon_spacing: float = 1.0, linewidth: float = 0.5, overlay: ArrayOrRdmDescriptor | None = None, overlay_color: str = '#00ff0050', overlay_symmetry: Symmetry = Symmetry.BOTH, contour: ArrayOrRdmDescriptor | None = None, contour_color: str = 'red', contour_symmetry: Symmetry = Symmetry.BOTH) Tuple[Figure, NDArray, Dict[int, Dict[str, Any]]][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_r’.

  • 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 (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 (Union[ArrayLike, str, None]) – boolean mask defining RDM elements to suppress (by default, the diagonal). Use the string “diagonal” to suppress the diagonal.

  • style (Union[str, 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.

  • overlay ((str, str) or NDArray) – RDM descriptor name-value tuple, or vector (one value per pair) which indicates whether to highlight the given cells

  • overlay_color (str) – Color to use to highlight the pairs in the overlay argument. Use RGBA to specify transparency. Default is 50% opaque green.

  • contour ((str, str) or NDArray) – RDM descriptor name-value tuple, or vector (one value per pair) which indicates whether to add a border to the given cells

  • contour_color (str) – Color to use for a border around pairs in the contour argument. Use RGBA to specify transparency. Default is red.

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 key at the first level is the axis index.

Return type:

Tuple[Figure, ArrayLike, Dict]

rsatoolbox.vis.rdm_plot.show_rdm_panel(rdms: rsatoolbox.rdm.RDMs, ax: Axes | None = None, cmap: str | Colormap = 'bone_r', nanmask: NDArray | None = None, rdm_descriptor: str | None = None, gridlines: ArrayLike | None = None, vmin: float | None = None, vmax: float | None = None, overlay: NDArray | None = None, overlay_color: str = '#00ff0050', overlay_symmetry: Symmetry = Symmetry.BOTH, contour: NDArray | None = None, contour_color: str = 'red', contour_symmetry: Symmetry = Symmetry.BOTH) 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_r’.

  • nanmask (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 (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.

  • overlay ((str, str) or NDArray) – RDM descriptor name-value tuple, or vector (one value per pair) which indicates whether to highlight the given cells

  • overlay_color (str) – Color to use to highlight the pairs in the overlay argument. Use RGBA to specify transparency. Default is 50% opaque green.

  • contour ((str, str) or NDArray) – RDM descriptor name-value tuple, or vector (one value per pair) which indicates whether to add a border to the given cells

  • contour_color (str) – Color to use for a border around pairs in the contour argument. Use RGBA to specify transparency. Default is red.

Returns:

Matplotlib handle.

Return type:

matplotlib.image.AxesImage