Repository navigation
Closed
Labels
Description
Description of the problem
Methodmne.Evoked.plot_topomap("interactive") allows the user to visualize topomap at the time point of their choice, through the bar below.

However, this function is found broken recently, when trying to change the time.

Steps to reproduce
Minimal code to reproduce:
import matplotlib.pyplot as plt
import mne
plt.ion()
data_path = mne.datasets.sample.data_path()
evoked_fname = data_path / "MEG/sample/sample_audvis-ave.fif"
evoked = mne.read_evokeds(evoked_fname, condition="Left Auditory").apply_baseline()
fig1 = evoked.plot_topomap("interactive")
plt.show(block=True)Link to data
No response
Expected results
The function should show the topomap correctly at time change event.
Actual results
The topomap breaks at immediate time change.
Additional information
Error log if helpful:
Traceback (most recent call last):
File "directory-to\mne-python\.venv\Lib\site-packages\matplotlib\cbook.py", line 361, in process
func(*args, **kwargs)
File "directory-to\mne-python\.venv\Lib\site-packages\matplotlib\widgets.py", line 592, in <lambda>
return self._observers.connect('changed', lambda val: func(val))
^^^^^^^^^
File "directory-to\mne-python\mne\viz\topomap.py", line 2741, in _slider_changed
publish(fig, TimeChange(time=val))
File "<decorator-gen-3>", line 12, in publish
File "directory-to\mne-python\mne\viz\ui_events.py", line 336, in publish
callback(event=event)
File "directory-to\mne-python\mne\viz\topomap.py", line 2878, in _on_time_change
im, _ = plot_topomap(data, pos, axes=ax, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "directory-to\mne-python\mne\viz\topomap.py", line 1182, in plot_topomap
return _plot_topomap(
^^^^^^^^^^^^^^
File "directory-to\mne-python\mne\viz\topomap.py", line 1452, in _plot_topomap
cmap = _get_cmap(cmap)
^^^^^^^^^^^^^^^
File "directory-to\mne-python\mne\viz\utils.py", line 2844, in _get_cmap
colormap = get_cmap(colormap)
^^^^^^^^^^^^^^^^^^
File "directory-to\mne-python\mne\viz\utils.py", line 2837, in get_cmap
return colormaps[cmap]
~~~~~~~~~^^^^^^
File "directory-to\mne-python\.venv\Lib\site-packages\matplotlib\cm.py", line 98, in __getitem__
raise KeyError(f"{item!r} is not a known colormap name") from None
KeyError: "('RdBu_r', True) is not a known colormap name"
A bit of investigation traces cmap back to lines 2644 - 2664 in mne/viz/topomap.py, after the PR #13866. This could be the possible cause.
Activity
Gnefil commentedon Jul 9, 2026
I would also suggest adding a unit test for future reference, testing the topomap interactivity.
Gnefil commentedon Jul 9, 2026
Would really appreciate some hands-on from @PragnyaKhandelwal. Is this something you can help with?
larsoner commentedon Jul 9, 2026
If not, I might be able to look tomorrow
PragnyaKhandelwal commentedon Jul 9, 2026
Hey @Gnefil — thanks for catching this! This is indeed a regression from #13866. The
_setup_cmap()helper returns a(cmap_name, is_draggable)tuple, and the interactive slider setup at line 2727 was accidentally passing the full tuple instead of just the name string. One-character fix:group_cmaps[0]→group_cmaps[0][0].I'll open a new PR with the fix and a unit test for the interactive path as you suggested. Should be up shortly!
TST: verify topomap redraws after interactive slider move (mne-toolsg…
Gnefil commentedon Jul 10, 2026
Thanks for the review and quick fix!