Skip to content

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

Open
frankier wants to merge 1 commit 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 1 commit 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?

Comment thread doc/changes/dev/13979.newfeature.rst Outdated
Comment thread mne/viz/epochs.py Outdated
Comment thread mne/viz/raw.py Outdated
Comment thread mne/utils/docs.py Outdated
Comment thread mne/io/base.py Outdated
@frankier frankier force-pushed the allow-figureclass-subclasses branch from df13f3b to d5e8ef6 Compare June 24, 2026 08:52
 * Allow subclasses of `MNEBrowseFigure` to be passed to plot_raw/plot_epochs, as well as the corresponding `plot(...)` methods of the raw and epochs classes.
 * Add an example showing onionskinning of MEG traces
@frankier frankier force-pushed the allow-figureclass-subclasses branch from d5e8ef6 to 98ab4b3 Compare June 24, 2026 09:02
@frankier

Copy link
Copy Markdown
Author

Okay I've tried to address all of these and added an example

@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.

Can you see if you can get pytest mne/tests/test_docstring_parameters.py to pass locally? CIs are still unhappy with the ordering

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

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.

single backtick is default linking mode (which for us is :py:obj: I think), if not adding to public API need code mode

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

Comment thread mne/utils/docs.py
and if absent, falls back to ``'estimated'``.
"""

docdict["figure_class"] = """

@larsoner larsoner Jun 24, 2026

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.

This is probably failing due to

>>> "_" < "u"
True

so needs to move down two more entries

Comment on lines +12 to +13
This example is "bad code" in a few ways:
* Since the interface for MNEBrowseFigure is not public, it is liable to

@larsoner larsoner Jun 24, 2026

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.

This currently renders as a definition list, which I don't think is what you meant? If supposed to just be bullets then

Suggested change
This example is "bad code" in a few ways:
* Since the interface for MNEBrowseFigure is not public, it is liable to
This example is "bad code" in a few ways:
* Since the interface for MNEBrowseFigure is not public, it is liable to

and fix other * to be not indented

@@ -0,0 +1,149 @@
"""
.. _ex-arrowmap:

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.

Wrong label, you can just remove it unless you specifically want to link to it in the docs

.. _ex-arrowmap:

==============================================================
Advanced plotting customization by subclassing MNEBrowseFigure

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 like the idea of the example! But from the output I'm not sure how exactly it differs from the default. Maybe you could 1) make the difference more obvious by only plotting a few channels, and 2) also call a standard .plot so both outputs show up and you can clearly see the difference

https://output.circle-artifacts.com/output/job/8c66d116-bd3a-4fd3-808e-9866f1edfcdc/artifacts/0/html/auto_examples/visualization/onionskin.html#sphx-glr-auto-examples-visualization-onionskin-py

Image

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