Skip to content

Allow subclasses of FigureClass to be passed to plot_raw/plot_epochs#13979

Open
frankier wants to merge 2 commits into
mne-tools:mainfrom
frankier:allow-figureclass-subclasses
Open

Allow subclasses of FigureClass to be passed to plot_raw/plot_epochs#13979
frankier wants to merge 2 commits into
mne-tools:mainfrom
frankier:allow-figureclass-subclasses

Conversation

@frankier

Copy link
Copy Markdown

What does this implement/fix?

This change allows for customization of raw/epoch plots via passing in a subclass of MNEBrowseFigure.

Currently I have achieved this in my own code through monkeypatching. This PR is the first steps towards cleaning things up to make extensions cleaner.

@welcome

welcome Bot commented Jun 23, 2026

Copy link
Copy Markdown

Hello! 👋 Thanks for opening your first pull request here! ❤️ We will try to get back to you soon. 🚴

@frankier frankier requested a review from larsoner as a code owner June 23, 2026 07:29

@larsoner larsoner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs should probably also mention that this param only affects the matplotlib plotting backend.

Do you think it's worth adding some version of this to an advanced raw viz example?

@@ -0,0 +1 @@
Allow subclasses of :class:`MNEBrowseFigure` to be passed to plot_raw/plot_epochs, as well as the corresponding plot(...) methods of the raw and epochs classes.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Allow subclasses of :class:`MNEBrowseFigure` to be passed to plot_raw/plot_epochs, as well as the corresponding plot(...) methods of the raw and epochs classes.
Allow subclasses of :class:`MNEBrowseFigure` to be passed to plot_raw/plot_epochs, as well as the corresponding plot(...) methods of the raw and epochs classes, by :newcontrib:`First Last`

then need a name -> url in doc/changes/names.inc

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... also, MNEBrowseFigure is not currently in the API docs. We either need to add it, or put this in double-backticks (code mode) as it currently can't link properly

Comment thread mne/viz/epochs.py

%(FigureClass)s

.. versionadded:: 1.12.2

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We won't backport so

Suggested change
.. versionadded:: 1.12.2
.. versionadded:: 1.13

Comment thread mne/viz/raw.py
%(verbose)s
%(FigureClass)s

.. versionadded:: 1.12.2

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Comment thread mne/utils/docs.py
# this is needed in test_docstring_parameters, which reads the file as text
docdict["¿test—üñɪçøɖɘ_keys*"] = "¿test—üñɪçøɖɘ_values*"

docdict["FigureClass"] = """

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pytest mne/tests/test_docstring_parameters.py complains about this not being in alphabetical order

Comment thread mne/io/base.py
overview_mode=None,
splash=True,
verbose=None,
FigureClass=None,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes sense to name this with snake case even though the class itself is probably upper camel case

Suggested change
FigureClass=None,
figure_class=None,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants