diff --git a/doc/changes/dev/13795.newfeature.rst b/doc/changes/dev/13795.newfeature.rst new file mode 100644 index 00000000000..fa885e7c9a3 --- /dev/null +++ b/doc/changes/dev/13795.newfeature.rst @@ -0,0 +1 @@ +Made ``evoked.plot()`` instantiate ``MNELineFigure`` when it creates its own figure, aligning this path with the ongoing 2D plotting figure-class refactor discussed in :gh:`7751`. diff --git a/mne/viz/_mpl_figure.py b/mne/viz/_mpl_figure.py index 47a26047768..4d33091e581 100644 --- a/mne/viz/_mpl_figure.py +++ b/mne/viz/_mpl_figure.py @@ -26,7 +26,7 @@ └ MNELineFigure Interactive figure for non-scrollable data. Generated by: - spectrum.plot() - - evoked.plot() TODO Not yet implemented + - evoked.plot() - evoked.plot_white() TODO Not yet implemented - evoked.plot_joint() TODO Not yet implemented """ diff --git a/mne/viz/evoked.py b/mne/viz/evoked.py index a62d2379f03..92600884fb2 100644 --- a/mne/viz/evoked.py +++ b/mne/viz/evoked.py @@ -452,10 +452,19 @@ def _plot_evoked( fig = None if axes is None: - fig, axes = plt.subplots(len(ch_types_used), 1, layout="constrained") - if isinstance(axes, plt.Axes): - axes = [axes] - fig.set_size_inches(6.4, 2 + len(axes)) + if plot_type == "butterfly" and hasattr(evoked, "get_channel_types"): + from ._mpl_figure import _line_figure + + fig, axes = _line_figure( + evoked, + picks=picks, + figsize=(6.4, 2 + len(ch_types_used)), + ) + else: + fig, axes = plt.subplots(len(ch_types_used), 1, layout="constrained") + if isinstance(axes, plt.Axes): + axes = [axes] + fig.set_size_inches(6.4, 2 + len(axes)) if isinstance(axes, plt.Axes): axes = [axes] diff --git a/mne/viz/tests/test_evoked.py b/mne/viz/tests/test_evoked.py index 9071bb8971c..8698cf525d8 100644 --- a/mne/viz/tests/test_evoked.py +++ b/mne/viz/tests/test_evoked.py @@ -126,6 +126,7 @@ def test_plot_evoked(): fig = evoked.plot( proj=True, hline=[1], exclude=[], window_title="foo", time_unit="s" ) + assert fig.__class__.__name__ == "MNELineFigure" amplitudes = _get_amplitudes(fig) assert len(amplitudes) == len(default_picks) assert evoked.proj is False