From 7e95b71ee09c91ccc08836df09cb1c2404366a70 Mon Sep 17 00:00:00 2001 From: ruuskas Date: Tue, 10 Dec 2024 13:10:58 +0200 Subject: [PATCH 1/6] Add fig.mne container for colorbar --- mne/viz/circle.py | 2 ++ mne/viz/tests/test_circle.py | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) 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..4a0a9597ca8 100644 --- a/mne/viz/tests/test_circle.py +++ b/mne/viz/tests/test_circle.py @@ -16,8 +16,10 @@ def test_plot_channel_labels_circle(): """Test plotting channel labels in a circle.""" fig, axes = plot_channel_labels_circle( dict(brain=["big", "great", "smart"]), - colors=dict(big="r", great="y", smart="b"), + 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() From 2b8a32781d021bcb491ab62a964aaba7536f658c Mon Sep 17 00:00:00 2001 From: ruuskas Date: Tue, 10 Dec 2024 13:23:57 +0200 Subject: [PATCH 2/6] Fix style --- mne/viz/tests/test_circle.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mne/viz/tests/test_circle.py b/mne/viz/tests/test_circle.py index 4a0a9597ca8..a92e672db28 100644 --- a/mne/viz/tests/test_circle.py +++ b/mne/viz/tests/test_circle.py @@ -16,7 +16,8 @@ def test_plot_channel_labels_circle(): """Test plotting channel labels in a circle.""" fig, axes = plot_channel_labels_circle( dict(brain=["big", "great", "smart"]), - colors=dict(big="r", great="y", smart="b"), colorbar=True + colors=dict(big="r", great="y", smart="b"), + colorbar=True ) # check that colorbar handle is returned assert isinstance(fig.mne.colorbar, matplotlib.colorbar.Colorbar) From e174692256fdd6d631d995acb75f43df05eafe16 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 10 Dec 2024 11:23:53 +0000 Subject: [PATCH 3/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- mne/viz/tests/test_circle.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mne/viz/tests/test_circle.py b/mne/viz/tests/test_circle.py index 4a0a9597ca8..c5f3719746b 100644 --- a/mne/viz/tests/test_circle.py +++ b/mne/viz/tests/test_circle.py @@ -16,7 +16,8 @@ def test_plot_channel_labels_circle(): """Test plotting channel labels in a circle.""" fig, axes = plot_channel_labels_circle( dict(brain=["big", "great", "smart"]), - colors=dict(big="r", great="y", smart="b"), colorbar=True + colors=dict(big="r", great="y", smart="b"), + colorbar=True, ) # check that colorbar handle is returned assert isinstance(fig.mne.colorbar, matplotlib.colorbar.Colorbar) From 0081fa7d2a076f3df96d6b8e44f57ccb73f6154d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 10 Dec 2024 11:27:30 +0000 Subject: [PATCH 4/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- mne/viz/tests/test_circle.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mne/viz/tests/test_circle.py b/mne/viz/tests/test_circle.py index a92e672db28..c5f3719746b 100644 --- a/mne/viz/tests/test_circle.py +++ b/mne/viz/tests/test_circle.py @@ -17,7 +17,7 @@ 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 + colorbar=True, ) # check that colorbar handle is returned assert isinstance(fig.mne.colorbar, matplotlib.colorbar.Colorbar) From b384b926766de370d02b66d6a02df27af301bca4 Mon Sep 17 00:00:00 2001 From: ruuskas Date: Tue, 10 Dec 2024 13:36:30 +0200 Subject: [PATCH 5/6] Add changelog entry --- doc/changes/devel/13019.newfeature.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changes/devel/13019.newfeature.rst diff --git a/doc/changes/devel/13019.newfeature.rst b/doc/changes/devel/13019.newfeature.rst new file mode 100644 index 00000000000..178cca9055d --- /dev/null +++ b/doc/changes/devel/13019.newfeature.rst @@ -0,0 +1 @@ +Add ``fig.mne`` container for :class:`Colorbar ` in :func:`mne.viz.circle._plot_connectivity_circle` to allow users to access it directly, by `Santeri Ruuskanen`_. \ No newline at end of file From b4bfd3a36e8842fe91428a25c7d473c5a5f11919 Mon Sep 17 00:00:00 2001 From: ruuskas Date: Tue, 10 Dec 2024 14:54:26 +0200 Subject: [PATCH 6/6] Fix changelog entry It seems that Sphinx is not a big fan of private functions so changed the ref to mne_connectivity.viz.plot_connectivity_circle. --- doc/changes/devel/13019.newfeature.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/changes/devel/13019.newfeature.rst b/doc/changes/devel/13019.newfeature.rst index 178cca9055d..6fe8ee492bf 100644 --- a/doc/changes/devel/13019.newfeature.rst +++ b/doc/changes/devel/13019.newfeature.rst @@ -1 +1 @@ -Add ``fig.mne`` container for :class:`Colorbar ` in :func:`mne.viz.circle._plot_connectivity_circle` to allow users to access it directly, by `Santeri Ruuskanen`_. \ No newline at end of file +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