Skip to content

Commit c1442fd

Browse files
larsonersnwnde
authored andcommitted
BUG: Fix bug with clip box setting (mne-tools#11999)
1 parent d388ec9 commit c1442fd

File tree

10 files changed

+24
-17
lines changed

10 files changed

+24
-17
lines changed

doc/changes/devel.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ Bugs
4747
- Fix bug with notebooks when using PyVista 0.42 by implementing ``trame`` backend support (:gh:`11956` by `Eric Larson`_)
4848
- Removed preload parameter from :func:`mne.io.read_raw_eyelink`, because data are always preloaded no matter what preload is set to (:gh:`11910` by `Scott Huberty`_)
4949
- Fix bug with :meth:`~mne.viz.Brain.add_annotation` when reading an annotation from a file with both hemispheres shown (:gh:`11946` by `Marijn van Vliet`_)
50+
- Fix bug with axis clip box boundaries in :func:`mne.viz.plot_evoked_topo` and related functions (:gh:`11999` by `Eric Larson`_)
5051
- Fix bug with ``subject_info`` when loading data from and exporting to EDF file (:gh:`11952` by `Paul Roujansky`_)
5152
- Fix handling of channel information in annotations when loading data from and exporting to EDF file (:gh:`11960` by `Paul Roujansky`_)
5253

doc/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@
200200
"Path": ":class:`python:pathlib.Path`",
201201
"bool": ":class:`python:bool`",
202202
# Matplotlib
203-
"colormap": ":doc:`colormap <matplotlib:tutorials/colors/colormaps>`",
203+
"colormap": ":ref:`colormap <matplotlib:colormaps>`",
204204
"color": ":doc:`color <matplotlib:api/colors_api>`",
205205
"Axes": "matplotlib.axes.Axes",
206206
"Figure": "matplotlib.figure.Figure",

examples/io/elekta_epochs.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
Getting averaging info from .fif files
66
======================================
77
8-
Parse averaging information defined in Elekta Vectorview/TRIUX DACQ (data
9-
acquisition). Extract and average epochs accordingly. Modify some
10-
averaging parameters and get epochs.
8+
Parse averaging information defined in Elekta Vectorview/TRIUX DACQ (data acquisition).
9+
Extract and average epochs accordingly. Modify some averaging parameters and get epochs.
1110
"""
1211
# Author: Jussi Nurminen (jnu@iki.fi)
1312
#

mne/utils/docs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75):
777777
cnorm : matplotlib.colors.Normalize | None
778778
How to normalize the colormap. If ``None``, standard linear normalization
779779
is performed. If not ``None``, ``vmin`` and ``vmax`` will be ignored.
780-
See :doc:`Matplotlib docs <matplotlib:tutorials/colors/colormapnorms>`
780+
See :ref:`Matplotlib docs <matplotlib:colormapnorms>`
781781
for more details on colormap normalization, and
782782
:ref:`the ERDs example<cnorm-example>` for an example of its use.
783783
"""

mne/viz/evoked.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2654,8 +2654,8 @@ def plot_compare_evokeds(
26542654
:class:`dict` of :class:`ints <int>` or :class:`floats <float>`
26552655
indicating steps or percentiles (respectively) along the colormap. If
26562656
``cmap`` is ``None``, list elements or dict values of ``colors`` must
2657-
be :class:`ints <int>` or valid :doc:`matplotlib colors
2658-
<matplotlib:tutorials/colors/colors>`; lists are cycled through
2657+
be :class:`ints <int>` or valid :ref:`matplotlib colors
2658+
<matplotlib:colors_def>`; lists are cycled through
26592659
sequentially,
26602660
while dicts must have keys matching the keys or conditions of an
26612661
``evokeds`` dict (see Notes for details). If ``None``, the current

mne/viz/misc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ def plot_events(
783783
Dictionary of event_id integers as keys and colors as values. If None,
784784
colors are automatically drawn from a default list (cycled through if
785785
number of events longer than list of default colors). Color can be any
786-
valid :doc:`matplotlib color <matplotlib:tutorials/colors/colors>`.
786+
valid :ref:`matplotlib color <matplotlib:colors_def>`.
787787
event_id : dict | None
788788
Dictionary of event labels (e.g. 'aud_l') as keys and their associated
789789
event_id values. Labels are used to plot a legend. If None, no legend

mne/viz/topo.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -496,8 +496,6 @@ def _imshow_tfr_unified(
496496
data_lines.append(
497497
ax.imshow(
498498
tfr[ch_idx],
499-
clip_on=True,
500-
clip_box=tuple(bn.pos),
501499
extent=extent,
502500
aspect="auto",
503501
origin="lower",
@@ -506,6 +504,7 @@ def _imshow_tfr_unified(
506504
cmap=cmap,
507505
)
508506
)
507+
data_lines[-1].set_clip_box(_pos_to_bbox(bn.pos, ax))
509508

510509

511510
def _plot_timeseries(
@@ -664,18 +663,17 @@ def _plot_timeseries_unified(
664663
pos = bn.pos
665664
data_lines = bn.data_lines
666665
ax = bn.ax
667-
# XXX These calls could probably be made faster by using collections
668666
for data_, color_, times_ in zip(data, color, times):
669667
data_lines.append(
670668
ax.plot(
671669
bn.x_t + bn.x_s * times_,
672670
bn.y_t + bn.y_s * data_[ch_idx],
673671
linewidth=0.5,
674672
color=color_,
675-
clip_on=True,
676-
clip_box=tuple(pos),
677673
)[0]
678674
)
675+
# Needs to be done afterward for some reason (probable matlotlib bug)
676+
data_lines[-1].set_clip_box(_pos_to_bbox(pos, ax))
679677
if vline:
680678
vline = np.array(vline) * bn.x_s + bn.x_t
681679
ax.vlines(
@@ -1300,3 +1298,13 @@ def plot_topo_image_epochs(
13001298
add_background_image(fig, fig_background)
13011299
plt_show(show)
13021300
return fig
1301+
1302+
1303+
def _pos_to_bbox(pos, ax):
1304+
"""Convert layout position to bbox."""
1305+
import matplotlib.transforms as mtransforms
1306+
1307+
return mtransforms.TransformedBbox(
1308+
mtransforms.Bbox.from_bounds(*pos),
1309+
ax.transAxes,
1310+
)

mne/viz/topomap.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2066,8 +2066,8 @@ def plot_evoked_topomap(
20662066
the same call as the colorbar. Note also that the colorbar will not be
20672067
resized automatically when ``axes`` are provided; use Matplotlib's
20682068
:meth:`axes.set_position() <matplotlib.axes.Axes.set_position>` method or
2069-
:doc:`gridspec <matplotlib:tutorials/intermediate/arranging_axes>`
2070-
interface to adjust the colorbar size yourself.
2069+
:ref:`gridspec <matplotlib:arranging_axes>` interface to adjust the colorbar
2070+
size yourself.
20712071
20722072
When ``time=="interactive"``, the figure will publish and subscribe to the
20732073
following UI events:

tutorials/preprocessing/70_fnirs_processing.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
1313
Here we will work with the :ref:`fNIRS motor data <fnirs-motor-dataset>`.
1414
"""
15-
1615
# %%
1716

1817
import numpy as np

tutorials/time-freq/20_sensors_time_frequency.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
1111
We will use this dataset: :ref:`somato-dataset`. It contains so-called event
1212
related synchronizations (ERS) / desynchronizations (ERD) in the beta band.
13-
""" # noqa: E501
13+
"""
1414
# Authors: Alexandre Gramfort <alexandre.gramfort@inria.fr>
1515
# Stefan Appelhoff <stefan.appelhoff@mailbox.org>
1616
# Richard Höchenberger <richard.hoechenberger@gmail.com>

0 commit comments

Comments
 (0)