Skip to content

Commit

Permalink
[ENH] Add fig.mne container for colorbar (#13019)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
2 people authored and larsoner committed Dec 18, 2024
1 parent fb30b5c commit fa28abf
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/changes/devel/13019.newfeature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +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`_.
2 changes: 2 additions & 0 deletions mne/viz/circle.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from functools import partial
from itertools import cycle
from types import SimpleNamespace

import numpy as np

Expand Down Expand Up @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions mne/viz/tests/test_circle.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit fa28abf

Please sign in to comment.