Skip to content

Commit a257c98

Browse files
ruuskaspre-commit-ci[bot]
authored andcommitted
[ENH] Add fig.mne container for colorbar (mne-tools#13019)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 2813e46 commit a257c98

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add ``fig.mne`` container for :class:`Colorbar <matplotlib.colorbar.Colorbar>` in :func:`plot_connectivity_circle <mne_connectivity.viz.plot_connectivity_circle>` to allow users to access it directly, by `Santeri Ruuskanen`_.

mne/viz/circle.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from functools import partial
88
from itertools import cycle
9+
from types import SimpleNamespace
910

1011
import numpy as np
1112

@@ -371,6 +372,7 @@ def _plot_connectivity_circle(
371372
cb_yticks = plt.getp(cb.ax.axes, "yticklabels")
372373
cb.ax.tick_params(labelsize=fontsize_colorbar)
373374
plt.setp(cb_yticks, color=textcolor)
375+
fig.mne = SimpleNamespace(colorbar=cb)
374376

375377
# Add callback for interaction
376378
if interactive:

mne/viz/tests/test_circle.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ def test_plot_channel_labels_circle():
1717
fig, axes = plot_channel_labels_circle(
1818
dict(brain=["big", "great", "smart"]),
1919
colors=dict(big="r", great="y", smart="b"),
20+
colorbar=True,
2021
)
22+
# check that colorbar handle is returned
23+
assert isinstance(fig.mne.colorbar, matplotlib.colorbar.Colorbar)
2124
texts = [
2225
child.get_text()
2326
for child in axes.get_children()

0 commit comments

Comments
 (0)