diff --git a/doc/changes/devel/13019.newfeature.rst b/doc/changes/devel/13019.newfeature.rst new file mode 100644 index 00000000000..6fe8ee492bf --- /dev/null +++ b/doc/changes/devel/13019.newfeature.rst @@ -0,0 +1 @@ +Add ``fig.mne`` container for :class:`Colorbar ` in :func:`plot_connectivity_circle ` to allow users to access it directly, by `Santeri Ruuskanen`_. \ No newline at end of file diff --git a/mne/viz/circle.py b/mne/viz/circle.py index fdcbd5a26bb..67a47c0d5fd 100644 --- a/mne/viz/circle.py +++ b/mne/viz/circle.py @@ -6,6 +6,7 @@ from functools import partial from itertools import cycle +from types import SimpleNamespace import numpy as np @@ -371,6 +372,7 @@ def _plot_connectivity_circle( cb_yticks = plt.getp(cb.ax.axes, "yticklabels") cb.ax.tick_params(labelsize=fontsize_colorbar) plt.setp(cb_yticks, color=textcolor) + fig.mne = SimpleNamespace(colorbar=cb) # Add callback for interaction if interactive: diff --git a/mne/viz/tests/test_circle.py b/mne/viz/tests/test_circle.py index a26379f6ccc..c5f3719746b 100644 --- a/mne/viz/tests/test_circle.py +++ b/mne/viz/tests/test_circle.py @@ -17,7 +17,10 @@ def test_plot_channel_labels_circle(): fig, axes = plot_channel_labels_circle( dict(brain=["big", "great", "smart"]), colors=dict(big="r", great="y", smart="b"), + colorbar=True, ) + # check that colorbar handle is returned + assert isinstance(fig.mne.colorbar, matplotlib.colorbar.Colorbar) texts = [ child.get_text() for child in axes.get_children()