Colorbar labels overlap in Brain plot without time viewer
See original GitHub issueWhen plotting an STC without the time viewer, the colorbar is arranged horizontally, causing the individual labels to overlap depending on the window size:
# %%
from pathlib import Path
import mne
mne.viz.set_3d_backend('pyvistaqt')
sample_dir = Path(mne.datasets.sample.data_path())
stc_fname = sample_dir / 'MEG' / 'sample' / 'sample_audvis-meg' # omit suffix
fs_subject = 'sample'
fs_subjects_dir = sample_dir / 'subjects'
stc = mne.read_source_estimate(fname=stc_fname, subject=fs_subject)
stc.plot(
time_viewer=False,
size=(300, 300),
subjects_dir=fs_subjects_dir
)
I’d suggest to only label the anchors and midpoint.
❯ mne sys_info
Platform: macOS-12.1-x86_64-i386-64bit
Python: 3.9.7 | packaged by conda-forge | (default, Sep 29 2021, 20:33:18) [Clang 11.1.0 ]
Executable: /Users/hoechenberger/miniforge3/envs/mne/bin/python3.9
CPU: i386: 8 cores
Memory: 16.0 GB
mne: 1.0.dev0
numpy: 1.21.4 {blas=NO_ATLAS_INFO, lapack=lapack}
scipy: 1.7.3
matplotlib: 3.5.0 {backend=MacOSX}
sklearn: 1.0.1
numba: 0.53.1
nibabel: 3.2.1
nilearn: 0.8.1
dipy: 1.4.1
cupy: Not found
pandas: 1.3.4
pyvista: 0.32.1 {OpenGL 4.1 INTEL-18.3.5 via Intel(R) Iris(TM) Plus Graphics OpenGL Engine}
pyvistaqt: 0.5.0
ipyvtklink: 0.2.1
vtk: 9.0.3
PyQt5: 5.12.3
ipympl: 0.8.2
mne_qt_browser: 0.1.7
pooch: v1.5.2
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (11 by maintainers)
Top Results From Across the Web
Colorbar axis label overlapping with ticks Matplotlib
I am plotting a scatterplot with a colorbar on the right using Matplotlib. The labels of the colorbar get overlapped/get too close with...
Read more >mne.viz.Brain — MNE 1.2.2 documentation
This is useful for viewing inflated surface where hemispheres typically overlap. Can be “auto” (default) use True with inflated surfaces and ...
Read more >Prevent colorbar label overlapping with subplots axis
An issue I regularly encounter is the titles for colour bars overlapping with the titles for the y-axis of a neighbouring subplot; and, ......
Read more >The fsbrain FAQ
If you experience this error, it most likely happened when you tried to plot something with a colorbar, and did not increase the...
Read more >surfer.Brain - PySurfer 0.10.0 documentation
If two hemispheres are being shown, an error will be thrown. remove_existingbool. If there is an existing contour overlay, remove it before plotting....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Fun fact, this wasn’t even possible in even the dev version of VTK until 9 months ago, mostly (I think?) because ParaView had their own subclass that did something similar. Fortunately it does look like VTK 9.1 included the change that allows doing it:
To me the best place to make all this accessible would be to subclass vtkScalarBarActor and implement at the PyVista backend as I mentioned above. The vtkScalarBarActor is currently accessible via
brain.plotter.scalar_bar
andbrain._scalar_bar
, so I say we change it tobrain.scalar_bar
(public name) and then makebrain.scalar_bar
have nice methods at the PyVista level. It’s much more in PyVista’s scope to provide convenience wrappers for VTK “stuff” than MNE-Python, so I’d rather work to solve the problem / implement a solution at their end with the help of their expertise!Sure
Not daily, but it does come up, and it does annoy me. Personally I’d also like it to be easy to set the colorbar tick values/locations manually… e.g. if I’m plotting negative log10 of a p-value on the brain, then certain specific values are interesting / important to signpost