Skip to content

ENH: allow per-channel colors in raw.plot via channel name dict keys#13765

Open
HansujaB wants to merge 3 commits intomne-tools:mainfrom
HansujaB:enh-add-custom-channel-colors-raw-plot
Open

ENH: allow per-channel colors in raw.plot via channel name dict keys#13765
HansujaB wants to merge 3 commits intomne-tools:mainfrom
HansujaB:enh-add-custom-channel-colors-raw-plot

Conversation

@HansujaB
Copy link
Copy Markdown
Contributor

Fixes #12658

What does this implement/fix?

Adds support for per‑channel color overrides in raw.plot by allowing the color dict to be keyed by channel names (with name keys taking precedence over type keys). Updates the docstring and adds a small matplotlib‑only test to verify the behavior.

Additional information

Backwards compatible: existing type‑based color dicts continue to work unchanged.

@HansujaB HansujaB requested a review from drammock as a code owner March 18, 2026 00:08
@HansujaB

This comment was marked as outdated.

Comment on lines +333 to +335
assert fig2.mne.ch_colors[0] == "red"
assert fig2.mne.ch_colors[1] == "k"
assert fig2.mne.ch_colors[2] == "k"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this tests whether the figure-attached metadata object mne.ch_colors has the right values. It doesn't confirm that the actual lines on the plot have the right colors. Can you adjust the test to verify that?

Copy link
Copy Markdown
Contributor Author

@HansujaB HansujaB Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@drammock Thanks a lot , I missed this I have added further tests to check plot lines also have right colour. Let me know if anything else needs to be changed I have also added the changelog entry!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add the possibility to provide custom color mapping for channels in raw.plot()

2 participants