Skip to content

Make blocking consistent#14098

Merged
drammock merged 5 commits into
mne-tools:mainfrom
cbrnr:mpl-block
Jul 25, 2026
Merged

Make blocking consistent#14098
drammock merged 5 commits into
mne-tools:mainfrom
cbrnr:mpl-block

Conversation

@cbrnr

@cbrnr cbrnr commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Fixes #13955.

Here's what I changed to make the blocking behavior consistent:

  • plot_evoked_topomap: removed hardcoded block=False (so this is now consistent with other plotting functions).
  • plot_sensors (plus corresponding methods): changed block=False to block=None (here the argument is useful to force blocking when needed for kind="select").
  • Spectrum.plot_topo, plot_psd_topo methods, plot_raw_psd_topo: deprecated the block argument since I don't think these functions need it.

So the behavior now is as follows: Since show=True by default, this essentially means that the functions call plt.show() internally. This shows the figure and blocks by default. Blocking can be changed via %matplotlib in IPython or plt.ion() in the regular Python REPL. I'm not sure about Jupyter notebooks, but I think whatever they do shouldn't have changed (they probably do not block by default).

@cbrnr
cbrnr requested review from agramfort and larsoner as code owners July 24, 2026 10:27
@cbrnr
cbrnr requested a review from wmvanvliet July 24, 2026 10:28

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

Okay for me, @drammock did you want to look?

Comment thread doc/changes/dev/14098.apichange.rst Outdated
Comment thread mne/time_frequency/spectrum.py Outdated
Comment thread mne/utils/docs.py Outdated
Comment thread mne/viz/raw.py Outdated
@wmvanvliet

wmvanvliet commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

now that show has its own docdict entry, there are some visualization functions whose docstrings should use it. That can be a separate PR.

@wmvanvliet

Copy link
Copy Markdown
Contributor

@drammock If you're happy with the docstring now feel free to merge.

@drammock
drammock merged commit 0b56ea2 into mne-tools:main Jul 25, 2026
29 checks passed
@drammock

Copy link
Copy Markdown
Member

Thanks @cbrnr !

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.

[DISCUSSION] Showing figures when running in non-interactive python: to block or not to block?

4 participants