ENH: Route evoked.plot() through MNELineFigure#13795
ENH: Route evoked.plot() through MNELineFigure#13795PragnyaKhandelwal wants to merge 6 commits intomne-tools:mainfrom
Conversation
When evoked.plot() creates its own figure (axes=None), now routes through _line_figure() to instantiate MNELineFigure instead of a plain matplotlib figure. This aligns with the 2D plotting figure-class refactor direction discussed in mne-tools#7751. Behavior unchanged for custom axes. Both plot_white() and plot_joint() remain out of scope here. Adds regression test to assert MNELineFigure instantiation for default path. Closes mne-tools#13747
|
Hi @larsoner, @drammock — just wanted to know the preferred direction for this refactor. |
|
Addressed review points @larsoner... could you please take another look when convenient? Thanks. |
|
Hi @larsoner, @drammock.......just a friendly ping. All checks are green and I’ve addressed the feedback from the previous review. |
|
Hi @PragnyaKhandelwal, as this changes plotting behavior, it needs visual inspection of the plots (not just the code) to make sure things still look correct. You can help speed up the review by:
(step 1 could be skipped in this case actually. Sometimes a screenshot is enough, but in this case we need to verify interactivity is preserved) |
|
Thanks for the guidance @drammock! I've completed the visual and architectural verification. Everything aligns with the current main branch while successfully migrating to the new figure class.
import mne
from mne.datasets import sample
from mne.viz._mpl_figure import MNELineFigure
data_path = sample.data_path()
evoked_fname = data_path / 'MEG' / 'sample' / 'sample_audvis-ave.fif'
evoked = mne.read_evokeds(evoked_fname, condition='Left Auditory')
fig = evoked.plot(spatial_colors=True)
print(f"Figure Class: {type(fig)}")
assert isinstance(fig, MNELineFigure)
print("Figure is an MNELineFigure `instance.")
|


Reference issue (if any)
Closes #13747
Related to #7751
What does this implement/fix?
When evoked.plot() creates its own figure (axes=None), it now routes through _line_figure() to instantiate MNELineFigure instead of a plain Matplotlib figure.
This aligns the default 2D plotting path with the refactor direction discussed in #7751, while keeping behavior unchanged when users pass custom axes.
Scope is intentionally limited:
evoked.plot_white() is out of scope
evoked.plot_joint() is out of scope
A regression test was added to assert MNELineFigure instantiation for the default evoked.plot() path.
Additional information
This is a localized, backward-compatible enhancement intended as an incremental step toward #7751, not a full closure of that broader refactor.