You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Avoid almost white colors in plots with spatial_colors=True #6686
As mentioned in #6678, spatial colors are sometimes almost white and therefore very hard to see. I think we should restrict these colors from getting almost white.
Reacted by Richard Höchenberger and Mikolaj Magnuski
I think we tweaked the spatial color mapping sometime in the last 4 years to make the light yellow less light so I'll close, but feel free to reopen if it's still an issue
I’ve also encountered the same issue with almost white colors when using spatial_colors=True in mne==1.9.0.
As pointed out by bboyth on the MNE Discourse, modifying the _rgb function in
.../env/lib/site-packages/mne/viz/evoked.py helped resolve the issue for me too.
Here’s the modified version of _rgb that worked:
def_rgb(x, y, z):
"""Transform x, y, z values into RGB colors."""rgb=np.array([x, y, z]).Trgb-=np.nanmin(rgb, 0)
rgb/=np.maximum(np.nanmax(rgb, 0), 1e-16) # avoid div by zero# Modification to avoid invisible colors:# Reduce RGB intensity for overly light colorsrgb[rgb.sum(axis=1) >2.5] =rgb[rgb.sum(axis=1) >2.5] -0.3returnrgb
Would it be possible to consider integrating this fix (or a similar safeguard) into a future release?
Activity
jona-sassenhagen commentedon Aug 24, 2019
sns.set_style('grey')cbrnr commentedon Aug 25, 2019
Is this the problem or the solution?
larsoner commentedon Oct 1, 2023
I think we tweaked the spatial color mapping sometime in the last 4 years to make the light yellow less light so I'll close, but feel free to reopen if it's still an issue
Mojackhak commentedon Jun 13, 2025
I’ve also encountered the same issue with almost white colors when using spatial_colors=True in mne==1.9.0.
As pointed out by bboyth on the MNE Discourse, modifying the _rgb function in
.../env/lib/site-packages/mne/viz/evoked.py helped resolve the issue for me too.
Here’s the modified version of _rgb that worked:
Would it be possible to consider integrating this fix (or a similar safeguard) into a future release?