# 3d plotting - empty plot

**URL:** <https://mne.discourse.group/t/3d-plotting-empty-plot/5656>\
**Category:** Support & Discussions\
**Tags:** visualization\
**Created:** [September 30, 2022, 4:14pm UTC](https://mne.discourse.group/t/3d-plotting-empty-plot/5656 "2022-09-30T16:14:31Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![astudenova](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/astudenova/32/1935_2.png) [@astudenova](https://mne.discourse.group/u/astudenova)\
**Post date:** [September 30, 2022, 4:14pm UTC](https://mne.discourse.group/t/3d-plotting-empty-plot/5656/1 "2022-09-30T16:14:32Z")

</div>

Hi!

I experience problems with 3d plotting. I used to use mayavi, but since it has been discontinued only matplotlib works for me (which looks a bit ugly). pyvistaqt 3d backend returns an empty plot.

I installed modules by “curl --remote-name [https://raw.githubusercontent.com/mne-tools/mne-python/main/environment.yml](https://raw.githubusercontent.com/mne-tools/mne-python/main/environment.yml)” and later using pip install.

MNE version 1.1.1  
System  
NAME=“Debian GNU/Linux”  
VERSION\_ID=“11”  
VERSION=“11 (bullseye)”  
VERSION\_CODENAME=bullseye  
ID=debian

I am trying to plot source estimate with a simple line stc.plot(subject). The subject is ‘fsaverage’.  
The output looks like that (below). When I press play, nothing is showing on the top plot, but the bottom plot is changing.

Thank you in advance!

 ![Screenshot_2022-09-30_17-17-37](https://global.discourse-cdn.com/free1/uploads/mne/original/2X/5/5d0db23ad8518e276204d7bdc10a0ce6c0b6f412.png)

---

<div class="post-metadata">

**Author:** ![drammock](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/drammock/32/4_2.png) [@drammock](https://mne.discourse.group/u/drammock)\
**Post date:** [September 30, 2022, 10:20pm UTC](https://mne.discourse.group/t/3d-plotting-empty-plot/5656/2 "2022-09-30T22:20:24Z")

</div>

1. can you try with [the MNE-Python sample data](https://mne.tools/stable/overview/datasets_index.html#sample), and see if the brain shows up in that case?

2. if that _doesn’t_ work, please share the result of `mne.sys_info()`

3. If it _does_ work with sample data but not with your data, please share a complete code sample, so we can hopefully see what might be going wrong. (It’s hard to tell if all we know is “I tried `stc.plot('fsaverage')` and it didn’t work”.) If possible include a link to the data file (if it’s huge, a cropped version of just 1-2 seconds is fine), so we can try to fully reproduce.

---

<div class="post-metadata">

**Author:** ![astudenova](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/astudenova/32/1935_2.png) [@astudenova](https://mne.discourse.group/u/astudenova)\
**Post date:** [October 2, 2022, 5:33pm UTC](https://mne.discourse.group/t/3d-plotting-empty-plot/5656/3 "2022-10-02T17:33:07Z")

</div>

Dear Dan,

Thank you for your suggestions! I apologize for the insufficient description.  
I downloaded sample data and followed this tutorial for plotting [Plotting with mne.viz.Brain — MNE 1.2.dev0 documentation](https://mne.tools/dev/auto_examples/visualization/brain.html#sphx-glr-auto-examples-visualization-brain-py). Unfortunately, the result is the same.

The output

```python
mne.sys_info()
Platform: Linux-5.10.0-17-amd64-x86_64-with-glibc2.31
Python: 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110]
Executable: /data/u_studenova_software/PycharmProjects/source-space-connectivity-optimization/venv/bin/python
CPU: : 24 cores
Memory: 250.9 GB
mne: 1.1.1
numpy: 1.23.3 {}
scipy: 1.9.1
matplotlib: 3.6.0Backend QtAgg is interactive backend. Turning interactive mode on.
 {backend=QtAgg}
sklearn: 1.1.2
numba: 0.56.2
nibabel: 4.0.2
nilearn: 0.9.2
dipy: 1.5.0
cupy: Not found
pandas: 1.5.0
pyvista: 0.36.1 {OpenGL 4.5 (Core Profile) Mesa 20.3.5 via llvmpipe (LLVM 11.0.1, 256 bits)}
pyvistaqt: 0.9.0
ipyvtklink: Matplotlib support failed
Traceback (most recent call last):
  File "/afs/cbs.mpg.de/software/pycharm/2022.2/debian-bullseye-amd64/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 25, in do_import
    succeeded = activate_func()
  File "/afs/cbs.mpg.de/software/pycharm/2022.2/debian-bullseye-amd64/plugins/python-ce/helpers/pydev/pydev_ipython/matplotlibtools.py", line 155, in activate_pylab
    pylab = sys.modules['pylab']
KeyError: 'pylab'
0.2.3
vtk: 9.1.0
qtpy: 2.2.0 {PyQt5=5.15.2}
ipympl: 0.9.2
pyqtgraph: 0.13.1
pooch: v1.6.0
mne_bids: Not found
mne_nirs: Not found
mne_features: Not found
mne_qt_browser: 0.4.0
mne_connectivity: Not found
mne_icalabel: Not found

```

Before starting, I made a fresh environment with pip-installed-modules from environment.yml file. Shall I now install “not found” and pylab?

---

<div class="post-metadata">

**Author:** ![richard](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/richard/32/15_2.png) [@richard](https://mne.discourse.group/u/richard)\
**Post date:** [October 2, 2022, 7:34pm UTC](https://mne.discourse.group/t/3d-plotting-empty-plot/5656/4 "2022-10-02T19:34:32Z")

</div>

Hello @astudenova, please follow our official installation instructions (using `conda` or our standalone installers, **not** `pip`) to ensure you end up with a working installation. It’s tricky getting everything working right “by hand” and with `pip` alone.

Best wishes,  
Richard

**Edit** I just now realized you’re relying on Notebook support for 3D rendering. I don’t think we have a similarly straightforward procedure as for the “non-Notebook” setup ☹ Sorry.

---

<div class="post-metadata">

**Author:** ![drammock](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/drammock/32/4_2.png) [@drammock](https://mne.discourse.group/u/drammock)\
**Post date:** [October 3, 2022, 7:57pm UTC](https://mne.discourse.group/t/3d-plotting-empty-plot/5656/5 "2022-10-03T19:57:09Z")

</div>

> [@astudenova](#):
>
> ```python
> matplotlib: 3.6.0Backend QtAgg is interactive backend. Turning interactive mode on.
> {backend=QtAgg}
> [...]
> ipyvtklink: Matplotlib support failed
> Traceback (most recent call last):
> File "/afs/cbs.mpg.de/software/pycharm/2022.2/debian-bullseye-amd64/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 25, in do_import
> succeeded = activate_func()
> File "/afs/cbs.mpg.de/software/pycharm/2022.2/debian-bullseye-amd64/plugins/python-ce/helpers/pydev/pydev_ipython/matplotlibtools.py", line 155, in activate_pylab
> pylab = sys.modules['pylab']
> KeyError: 'pylab'
> 
> ```

I’ve never seen this error occurring as part of `mne.sys_info()`. @larsoner any notion of what might be going on there?

---

<div class="post-metadata">

**Author:** ![larsoner](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/larsoner/32/3_2.png) [@larsoner](https://mne.discourse.group/u/larsoner)\
**Post date:** [October 3, 2022, 8:25pm UTC](https://mne.discourse.group/t/3d-plotting-empty-plot/5656/6 "2022-10-03T20:25:27Z")

</div>

In the latest traceback, it looks like this is a bug with `pylab` rather than MNE.

For the missing brains, did you try the fixes outlined here for the MESA renderer?

[https://mne.tools/dev/install/advanced.html#off-screen-rendering-with-mesa](https://mne.tools/dev/install/advanced.html#off-screen-rendering-with-mesa)

I think in 1.2 we try to autodetect MESA and do the equivalent of `mne.viz.set_3d_options(multi_samples=1)`, which will hopefully fix the issue here!

---

<div class="post-metadata">

**Author:** ![astudenova](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/astudenova/32/1935_2.png) [@astudenova](https://mne.discourse.group/u/astudenova)\
**Post date:** [October 4, 2022, 8:41am UTC](https://mne.discourse.group/t/3d-plotting-empty-plot/5656/7 "2022-10-04T08:41:12Z")

</div>

Good day!

Thank you very much for suggestions!  
I went through conda installations, but it did not solve the problem.  
But mne.viz.set\_3d\_options(antialias=False) did! mne.sys\_info() runs without errors, and I got my brain back! Thank you!

---

<div class="post-metadata">

**Author:** ![tbonesung](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/tbonesung/32/3365_2.png) [@tbonesung](https://mne.discourse.group/u/tbonesung)\
**Post date:** [April 18, 2024, 6:44pm UTC](https://mne.discourse.group/t/3d-plotting-empty-plot/5656/8 "2024-04-18T18:44:46Z")

</div>

Hello!

I was also trying to do stc.plot() with my linux system. However, I keep getting the error ‘Cannot connect to a valid display’. Is there another setting to configure for 3D visualization? Thank you in advance!
