mne_denoise.viz.plot_metric_comparison#

mne_denoise.viz.plot_metric_comparison(data, metric_col, metric_label=None, group_col='group', subject_col='subject', group_order=None, group_colors=None, group_labels=None, title='Metric Comparison', reference_value=None, reference_label='Reference', ax=None, fname=None, show=True)[source]#

Plot one metric as grouped bars or paired subject trajectories.

Parameters:
  • data (mapping of str to array-like) – Columnar mapping with at least group_col and one numeric metric.

  • metric_col (str) – Metric column to visualize.

  • metric_label (str | None) – Y-axis label. If None, derived from metric_col.

  • group_col (str) – Grouping column name.

  • subject_col (str) – Subject identifier column for paired overlays.

  • group_order (list of str | None) – Optional explicit group order. If None, first-seen order is used.

  • group_colors (dict | None) – Optional style overrides keyed by group.

  • group_labels (dict | None) – Optional style overrides keyed by group.

  • title (str) – Axes title.

  • reference_value (float | None) – Optional horizontal reference line.

  • reference_label (str) – Legend label for reference_value.

  • ax (matplotlib.axes.Axes | None) – Existing axes. If None, create a new figure.

  • fname (path-like | None) – Optional output path when creating a new figure.

  • show (bool) – Whether to display the figure when creating a new figure.

Returns:

fig – Figure containing the plot.

Return type:

matplotlib.figure.Figure

Examples

>>> import numpy as np
>>> from mne_denoise.viz import plot_metric_comparison
>>> data = {
...     "subject": np.array(["s1", "s1", "s2", "s2"]),
...     "group": np.array(["A", "B", "A", "B"]),
...     "score": np.array([1.1, 0.8, 1.0, 0.7]),
... }
>>> fig = plot_metric_comparison(
...     data,
...     group_col="group",
...     subject_col="subject",
...     metric_col="score",
...     show=False,
... )