Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mne.viz.plot_compare_evokeds should not draw colorbar legend when legend=False #11451

Open
mmagnuski opened this issue Feb 4, 2023 · 5 comments

Comments

@mmagnuski
Copy link
Member

When a colormap is passed to mne.viz.plot_compare_evokeds (for example cbar='viridis') it places a colorbar next to the axis (instead of a normal in-axis legend). While the presence of the standard legend can be controlled with legend=False, the colorbar legend is always drawn.

Example:

import numpy as np
import mne

info = mne.create_info(ch_names=list('ABCDE'), sfreq=50., ch_types='eeg')

conditions = ['cond1', 'cond2']
evokeds = dict()
for condition in conditions:
    data = np.random.random((5, 100)) * 1e-6
    evokeds[condition] = mne.EvokedArray(data, info, tmin=-0.25)

legend=False controls whether standard legend is drawn:

mne.viz.plot_compare_evokeds(evokeds)

image

mne.viz.plot_compare_evokeds(evokeds, legend=False)

image

However, when cbar argument is used, the colormap legend is always drawn:

mne.viz.plot_compare_evokeds(evokeds, cmap='viridis', legend=False)

image

I think legend=False should not plot the colorbar.

@hoechenberger
Copy link
Member

I didn't know that feature existed! Why do we even have that? They're both essentially doing the same, no??

@mmagnuski
Copy link
Member Author

The colorbar feature might be useful for variables with continuous meaning (contrast for example). I think this scenario is assumed when you specify a colormap with cmap.

@mmagnuski
Copy link
Member Author

take a look at this example for instance:
https://mne.tools/stable/auto_examples/stats/sensor_regression.html

@hoechenberger
Copy link
Member

Makes sense!

@drammock
Copy link
Member

drammock commented Feb 7, 2023

hmm. interestingly mne.viz.plot_compare_evokeds(evokeds, cmap='viridis', legend=True) does not show the in-axes legend. It's been a while since I've touched this code... does it make sense that if you specify cmap then you will never get an in-axes legend? If so, then it could be safe to use legend to control in-axes legend when cmap=None and control colorbar when cmap is not None.

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

No branches or pull requests

3 participants