Skip to content

Commit

Permalink
[MRG] Fix clicking on an axis of mne.viz.plot_evoked_topo when multip…
Browse files Browse the repository at this point in the history
…le vertical lines are added (mne-tools#12345)
  • Loading branch information
Mathieu Scheltienne authored and snwnde committed Mar 20, 2024
1 parent c8c7e21 commit fcc692a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions doc/changes/devel/12345.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix clicking on an axis of :func:`mne.viz.plot_evoked_topo` when multiple vertical lines ``vlines`` are used, by `Mathieu Scheltienne`_.
2 changes: 1 addition & 1 deletion mne/viz/evoked.py
Original file line number Diff line number Diff line change
Expand Up @@ -1218,7 +1218,7 @@ def plot_evoked_topo(
If true SSP projections are applied before display. If 'interactive',
a check box for reversible selection of SSP projection vectors will
be shown.
vline : list of float | None
vline : list of float | float| None
The values at which to show a vertical line.
fig_background : None | ndarray
A background image for the figure. This must work with a call to
Expand Down
14 changes: 9 additions & 5 deletions mne/viz/topo.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from .._fiff.pick import channel_type, pick_types
from ..defaults import _handle_default
from ..utils import Bunch, _check_option, _clean_names, _to_rgb, fill_doc
from ..utils import Bunch, _check_option, _clean_names, _is_numeric, _to_rgb, fill_doc
from .utils import (
DraggableColorbar,
_check_cov,
Expand Down Expand Up @@ -631,10 +631,14 @@ def _rm_cursor(event):
else:
ax.set_ylabel(y_label)

if vline:
plt.axvline(vline, color=hvline_color, linewidth=1.0, linestyle="--")
if hline:
plt.axhline(hline, color=hvline_color, linewidth=1.0, zorder=10)
if vline is not None:
vline = [vline] if _is_numeric(vline) else vline
for vline_ in vline:
plt.axvline(vline_, color=hvline_color, linewidth=1.0, linestyle="--")
if hline is not None:
hline = [hline] if _is_numeric(hline) else hline
for hline_ in hline:
plt.axhline(hline_, color=hvline_color, linewidth=1.0, zorder=10)

if colorbar:
plt.colorbar()
Expand Down

0 comments on commit fcc692a

Please sign in to comment.