Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MRG] Fix clicking on an axis of mne.viz.plot_evoked_topo when multiple vertical lines are added #12345

Merged
merged 8 commits into from
Jan 10, 2024

Conversation

mscheltienne
Copy link
Member

@mscheltienne mscheltienne commented Jan 10, 2024

Code snippet to reproduce:

from mne import Epochs, find_events
from mne.datasets import sample
from mne.io import read_raw_fif
from mne.viz import plot_evoked_topo


directory = sample.data_path()
fname = directory / "MEG" / "sample" / "sample_audvis_filt-0-40_raw.fif"
raw = read_raw_fif(fname, preload=False)
raw.pick(("eeg", "stim")).load_data()
events = find_events(raw)
epochs = Epochs(raw, events, dict(cond1=1, cond2=2), tmin=-0.2, tmax=0.5, preload=True)
evokeds = {"cond1": epochs["cond1"].average(), "cond2": epochs["cond2"].average()}
fig = plot_evoked_topo(
    [evokeds["cond1"], evokeds["cond2"]],
    color=["#3498DB", "gray"],
    vline=[0, 0.080],
)

On main, clicking on axis yields:

Traceback (most recent call last):
  File "c:\Users\scheltie\pyvenv\mscheltienne\mne-python\lib\site-packages\matplotlib\cbook.py", line 298, in process
    func(*args, **kwargs)
  File "C:\Users\scheltie\git\mscheltienne\mne-python\mne\viz\topo.py", line 380, in _plot_topo_onpick
    show_func(ax, ch_idx)
  File "C:\Users\scheltie\git\mscheltienne\mne-python\mne\viz\topo.py", line 635, in _plot_timeseries
    plt.axvline(vline, color=hvline_color, linewidth=1.0, linestyle="--")
  File "c:\Users\scheltie\pyvenv\mscheltienne\mne-python\lib\site-packages\matplotlib\pyplot.py", line 2716, in axvline
    return gca().axvline(x=x, ymin=ymin, ymax=ymax, **kwargs)
  File "c:\Users\scheltie\pyvenv\mscheltienne\mne-python\lib\site-packages\matplotlib\axes\_axes.py", line 849, in axvline
    scalex = (xx < xmin) or (xx > xmax)
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

@mscheltienne mscheltienne changed the title Fix clicking on an axis of mne.viz.plot_evoked_topo when multiple vertical lines are added [MRG] Fix clicking on an axis of mne.viz.plot_evoked_topo when multiple vertical lines are added Jan 10, 2024
@mscheltienne
Copy link
Member Author

Failure is unrelated.

mne/viz/topo.py Outdated Show resolved Hide resolved
@mscheltienne mscheltienne enabled auto-merge (squash) January 10, 2024 16:41
@mscheltienne mscheltienne merged commit 4f1557d into mne-tools:main Jan 10, 2024
29 checks passed
snwnde pushed a commit to snwnde/mne-python that referenced this pull request Mar 20, 2024
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