-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[BUG] Evoked.plot_topomap()
and Evoked.plot_joint()
handle the colormaps in a suboptimal manner
#13050
Comments
Hello! 👋 Thanks for opening your first issue here! ❤️ We will try to get back to you soon. 🚴 |
I had seen some colorbar badness and assumed it was a matplotlib bug, it would be great if working this out fixed it!
To build this out a bit more, I think from a user perspective the most intuitive behavior would be:
WDYT? |
case (3) could end up looking really weird if the user's most extreme chosen |
Yeah that's my feeling in that case. And they can work around it easily with (4) if they want. |
Sorry for the delay, I forgot to reply after checking the comments last week.
This sounds good to me. The only possible problem I see here is that in case (1), it is possible that the contours with the largest absolute values might be quite a bit smaller than For the implementation of the above, I would probably use |
Perhaps the colorbar limits in all cases should be capped wherever the |
That could be one solution. In that case, there wouldn't be ticks at the extrema, since |
I think that's okay. That's often the case for matplotlib plots so perhaps expected behavior |
Ok. I can implement that and see if it works as expected. |
Let's continue this in #13063 |
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Eric Larson <[email protected]>
* upstream/main: (57 commits) Allow lasso selection sensors in a plot_evoked_topo (mne-tools#12071) MAINT: Fix doc build (mne-tools#13076) BUG: Improve sklearn compliance (mne-tools#13065) [pre-commit.ci] pre-commit autoupdate (mne-tools#13073) MAINT: Add Numba to 3.13 test (mne-tools#13075) Bump autofix-ci/action from ff86a557419858bb967097bfc916833f5647fa8c to 551dded8c6cc8a1054039c8bc0b8b48c51dfc6ef in the actions group (mne-tools#13071) [BUG] Correct annotation onset for exportation to EDF and EEGLAB (mne-tools#12656) New feature for removing heart artifacts from EEG or ESG data using a Principal Component Analysis - Optimal Basis Sets (PCA-OBS) algorithm (mne-tools#13037) [BUG] Fix taper weighting in computation of TFR multitaper power (mne-tools#13067) [FIX] Reading an EDF with preload=False and mixed frequency (mne-tools#13069) Fix evoked topomap colorbars, closes mne-tools#13050 (mne-tools#13063) [pre-commit.ci] pre-commit autoupdate (mne-tools#13060) BUG: Fix bug with interval calculation (mne-tools#13062) [DOC] extend documentation for add_channels (mne-tools#13051) Add `combine_tfr` to API (mne-tools#13054) Add `combine_spectrum()` function and allow `grand_average()` to support `Spectrum` data (mne-tools#13058) BUG: Fix bug with helium anon (mne-tools#13056) [ENH] Add option to store and return TFR taper weights (mne-tools#12910) BUG: viz plot window's 'title' argument showed no effect. (mne-tools#12828) MAINT: Ensure limited set of tests are skipped (mne-tools#13053) ...
Description of the problem
This might be somewhat controversial as a bug report and is partially a matter of taste.
There is a combination of two issues, which leads to suboptimal results when producing plots with the default parameters using
Evoked.plot_topomap()
andEvoked.plot_joint()
.Essentially, an unpredictable amount of whitespace is left above and below the colored portion of the colorbar when using
Evoked.plot_topomap()
. This is seen in all MNE examples using topomaps, for example, Plotting topographic maps of evoked data. The reason is that the colorbar ticks follow thecontours
(as they should), while the colored part is dependent onvlim
(by default set symmetrically such thatvmax = np.abs(data).max()
). The default behavior is to set sixcontours
usingmatplotlib.ticker.MaxNLocator
, which adds locations beyond the minimum and maximum of the data to obtain "nice" values for the ticks. I wonder if it would be better to scale then also the colormap limits to match the smallest and largest ticks?This issue can, of course, be circumvented by explicitly setting both
vlim
andcontours
.Moreover, when using
Evoked.plot_joint()
without specifyingvlim
, thevlim
for the topomaps are selected based on the data at the selected time points (insideplot_evoked_topomap
). At the same time, the contours, and correspondingly, the colorbar ticks, are selected based on theylim
of the time series plot. In my opinion, it would be better to do the following:vlim
are specified for the topomap, use thosevlim
also to set the contours (unlesscontours
are set explicitly). The current behavior is to use theylim
from the time series plot to determine the contours unlesscontours
is set explicitly.vlim
are not specified for the topomap, set the contours similar to what is now done inEvoked.plot_topomap()
, usingvmax = np.abs(data).max()
at the topomap timepoints.Steps to reproduce
Link to data
No response
Expected results
I would like it to do this:
Actual results
Instead this happens:
Here's an example of what happens when suboptimal time points are picked:
Additional information
I don't know if this is a feature or a bug, but here's to open discussion. I can make a PR if this is something that you want to change.
The text was updated successfully, but these errors were encountered: