stc.plot with pos_lim parameter and a divergent colormap does not plot negative values


I’m having a problem with stc.plot function. I want to use a divergent colormap when plotting the source estimate which includes negative values as well as positive ones. Mne documentation suggests using pos_lim instead of lim for divergent colormaps. Therefore, I used pos_lim as following:
brain = stc.plot(**kwargs, colormap=‘seismic’, clim=dict(kind=‘value’, pos_lims=[0, 300, 600]))

What I expected from this was to have a plot with negative and positive values with a scale of [-600, 600] however I ended up with having only positive values and scale of [0,600] in resulting plot.

So, I’d like to ask if there is any other parameter that I need to set to make this work?

Thank you!

Hello @pgoktepe and welcome to the forum!

Which version of MNE-Python are you using?

I cannot reproduce your problem with the following code:

# %%
from pathlib import Path
import mne


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)

brain = stc.plot(
    views=('lateral', 'medial'),
    clim=dict(kind='value', pos_lims=[0, 300, 600])

Hello @richard! Thanks for your incredibly fast response!

The mne version I’m using is 0.21.0. When I looked at the code snippet you sent, I saw that you’re using pyvista as the mne backend. I’m using mayavi. So, do you think that could be the reason?

I tried changing that to pyvista but now I’m getting an error saying BackgroundPlotter is no longer accessible by pyvista.BackgroundPlotter

Thanks for your help!

Hello, please update to MNE-Python 0.23.1, as it includes numerous fixes and improvements compared to 0.21. The PyVista backend provides a greatly improved plotting experience, so you don’t want to miss out on that anyway :sunglasses:

Updating mne to 0.23.1 solved the issue when running with mayavi however I got another error "type object ‘Language’ has no attribute ‘English’ " when I tried using PyVista.

Thank you so much for your help! :slight_smile:

1 Like