mne-tools / mne-tools/mne-python
mne.viz.plot_compare_evokeds should not draw colorbar legend when `legend=False`
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 3.5k
- Forks
- 1.6k
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 100
Description
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)

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

However, when cbar argument is used, the colormap legend is always drawn:
mne.viz.plot_compare_evokeds(evokeds, cmap='viridis', legend=False)

I think legend=False should not plot the colorbar.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the mne.viz.plot_compare_evokeds entry point and reproduce the issue with the example in the report, using a colormap and legend=False. Trace where the colorbar is created; done means legend=False suppresses both the standard legend and colorbar, while the colorbar remains available when legend is enabled.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100