# Plotting issues MNE 1.5.1, matplotlib backend choice?

**URL:** <https://mne.discourse.group/t/plotting-issues-mne-1-5-1-matplotlib-backend-choice/8741>\
**Category:** Support & Discussions\
**Created:** [May 3, 2024, 9:03am UTC](https://mne.discourse.group/t/plotting-issues-mne-1-5-1-matplotlib-backend-choice/8741 "2024-05-03T09:03:34Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![deniz\_yilmaz](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/deniz_yilmaz/32/4497_2.png) [@deniz\_yilmaz](https://mne.discourse.group/u/deniz_yilmaz)\
**Post date:** [May 3, 2024, 9:03am UTC](https://mne.discourse.group/t/plotting-issues-mne-1-5-1-matplotlib-backend-choice/8741/1 "2024-05-03T09:03:35Z")

</div>

Hi everyone,

It might be a messy explanation since I do not understand what exactly is going on, so please bear with me:

Plotting somehow works inconsistently for me, such that sometimes I can plot interactive pop-up windows and sometimes in the plot pane. This worked all right (playing around with matplotlib backends, even though I did not fully grasp what was happening under the hood) until recently.

For some reason, I am not able to plot as before, (pop-up windows open empty and show a loading sign for hours), and often the plot won’t even appear on the plotting pane, e.g.

```python
 heartbeat_evoked_v1.plot()
Traceback (most recent call last):

  File /Applications/MNE-Python/1.5.1_0/.mne-python/lib/python3.11/site-packages/IPython/core/formatters.py:340 in __call__
    return printer(obj)

  File /Applications/MNE-Python/1.5.1_0/.mne-python/lib/python3.11/site-packages/IPython/core/pylabtools.py:152 in print_figure
    fig.canvas.print_figure(bytes_io, **kw)

  File /Applications/MNE-Python/1.5.1_0/.mne-python/lib/python3.11/site-packages/matplotlib/backends/backend_qtagg.py:75 in print_figure
    super().print_figure(*args, **kwargs)

  File /Applications/MNE-Python/1.5.1_0/.mne-python/lib/python3.11/site-packages/matplotlib/backend_bases.py:2353 in print_figure
    restore_bbox = _tight_bbox.adjust_bbox(

  File /Applications/MNE-Python/1.5.1_0/.mne-python/lib/python3.11/site-packages/matplotlib/_tight_bbox.py:28 in adjust_bbox
    ax.apply_aspect(locator(ax, None))

  File /Applications/MNE-Python/1.5.1_0/.mne-python/lib/python3.11/site-packages/mpl_toolkits/axes_grid1/inset_locator.py:73 in __call__
    bbox = self.get_window_extent(renderer)

  File /Applications/MNE-Python/1.5.1_0/.mne-python/lib/python3.11/site-packages/matplotlib/offsetbox.py:399 in get_window_extent
    renderer = self.figure._get_renderer()

AttributeError: 'NoneType' object has no attribute '_get_renderer'

Out[20]: <Figure size 920x432 with 2 Axes>

```

or

```python
heartbeat_evoked_v1.plot
Out[21]: <bound method Evoked.plot of <Evoked | '0.00 × Comment/actiCAP Data On + 0.00 × New Segment/ + 1.00 × R-peak' (average, N=390), -0.3 – 0.8 s, baseline -0.3 – 0 s, 31 ch, ~110 kB>>

```

but no plot appearing

I figured I needed to update conda and MNE but hit a dead end because I could not update anything due to this error I was not able to circumvent even though I tried many recommended solutions:

```python
(mne-1.5.1_0) denizyilmaz@Denizs-MacBook-Pro ~ % conda update anaconda
conda install spyder=5.5.1

Error while loading conda entry point: conda-libmamba-solver (dlopen(/Users/denizyilmaz/anaconda3/lib/python3.11/site-packages/libmambapy/bindings.cpython-311-darwin.so, 0x0002): Library not loaded: @rpath/libarchive.19.dylib
  Referenced from: <9391E88D-A5AA-33C9-8306-75BC6FFBC365> /Users/denizyilmaz/anaconda3/lib/libmamba.2.0.0.dylib
  Reason: tried: '/Users/denizyilmaz/anaconda3/lib/libarchive.19.dylib' (no such file), '/Users/denizyilmaz/anaconda3/lib/python3.11/site-packages/libmambapy/../../../libarchive.19.dylib' (no such file), '/Users/denizyilmaz/anaconda3/lib/python3.11/site-packages/libmambapy/../../../libarchive.19.dylib' (no such file), '/Users/denizyilmaz/anaconda3/bin/../lib/libarchive.19.dylib' (no such file), '/Users/denizyilmaz/anaconda3/bin/../lib/libarchive.19.dylib' (no such file), '/usr/local/lib/libarchive.19.dylib' (no such file), '/usr/lib/libarchive.19.dylib' (no such file, not in dyld cache))

```

When I run the following command on my working session, where unexpectedly pop-up interactive plotting did work:

```python
import mne
mne.sys_info() 

Platform macOS-14.0-arm64-i386-64bit
Python 3.11.5 | packaged by conda-forge | (main, Aug 27 2023, 03:33:12) [Clang 15.0.7]
Executable /Applications/MNE-Python/1.5.1_0/.mne-python/bin/python
CPU i386 (10 cores)
Memory 16.0 GB

Core
├☑ mne 1.5.1
├☑ numpy 1.24.4 (OpenBLAS 0.3.24 with 10 threads)
├☑ scipy 1.11.2
├☑ matplotlib 3.7.2 (backend=TkAgg)
├☑ pooch 1.7.0
└☑ jinja2 3.1.2

Numerical (optional)
├☑ sklearn 1.3.0
├☑ numba 0.57.1
├☑ nibabel 5.0.1
├☑ nilearn 0.10.1
├☑ dipy 1.7.0
├☑ openmeeg 2.5.6
├☑ pandas 2.1.0
└☐ unavailable cupy

Visualization (optional)
├☑ pyvista 0.41.1 (OpenGL 4.1 Metal - 86 via Apple M1 Pro)
├☑ pyvistaqt 0.0.0
├☑ vtk 9.2.6
├☑ qtpy 2.4.0 (PyQt5=5.15.8)
Exception in Tkinter callback
Traceback (most recent call last):
  File "/Applications/MNE-Python/1.5.1_0/.mne-python/lib/python3.11/tkinter/ __init__.py", line 1948, in __call__
    return self.func(*args)
           ^^^^^^^^^^^^^^^^
  File "/Applications/MNE-Python/1.5.1_0/.mne-python/lib/python3.11/site-packages/matplotlib/backends/_backend_tk.py", line 552, in destroy
    Gcf.destroy(self)
  File "/Applications/MNE-Python/1.5.1_0/.mne-python/lib/python3.11/site-packages/matplotlib/_pylab_helpers.py", line 66, in destroy
    manager.destroy()
  File "/Applications/MNE-Python/1.5.1_0/.mne-python/lib/python3.11/site-packages/matplotlib/backends/_backend_tk.py", line 587, in destroy
    delayed_destroy()
  File "/Applications/MNE-Python/1.5.1_0/.mne-python/lib/python3.11/site-packages/matplotlib/backends/_backend_tk.py", line 577, in delayed_destroy
    self.window.destroy()
  File "/Applications/MNE-Python/1.5.1_0/.mne-python/lib/python3.11/tkinter/ __init__.py", line 2368, in destroy
    self.tk.call('destroy', self._w)
_tkinter.TclError: can't invoke "destroy" command: application has been destroyed
Exception in Tkinter callback
Traceback (most recent call last):
  File "/Applications/MNE-Python/1.5.1_0/.mne-python/lib/python3.11/tkinter/ __init__.py", line 1948, in __call__
    return self.func(*args)
           ^^^^^^^^^^^^^^^^
  File "/Applications/MNE-Python/1.5.1_0/.mne-python/lib/python3.11/site-packages/matplotlib/backends/_backend_tk.py", line 552, in destroy
    Gcf.destroy(self)
  File "/Applications/MNE-Python/1.5.1_0/.mne-python/lib/python3.11/site-packages/matplotlib/_pylab_helpers.py", line 66, in destroy
    manager.destroy()
  File "/Applications/MNE-Python/1.5.1_0/.mne-python/lib/python3.11/site-packages/matplotlib/backends/_backend_tk.py", line 587, in destroy
    delayed_destroy()
  File "/Applications/MNE-Python/1.5.1_0/.mne-python/lib/python3.11/site-packages/matplotlib/backends/_backend_tk.py", line 577, in delayed_destroy
    self.window.destroy()
  File "/Applications/MNE-Python/1.5.1_0/.mne-python/lib/python3.11/tkinter/ __init__.py", line 2368, in destroy
    self.tk.call('destroy', self._w)
_tkinter.TclError: can't invoke "destroy" command: application has been destroyed
2024-05-03 10:36:55,576 - OpenGL.acceleratesupport - INFO - No OpenGL_accelerate module loaded: No module named 'OpenGL_accelerate'
├☑ pyqtgraph 0.13.3
├☑ mne-qt-browser 0.5.2
├☑ ipywidgets 8.1.0
├☑ trame_client 2.11.2
├☑ trame_server 2.11.7
├☑ trame_vtk 2.5.8
├☑ trame_vuetify 2.3.1
└☐ unavailable ipympl

Ecosystem (optional)
├☑ mne-bids 0.13
├☑ mne-nirs 0.5.0
├☑ mne-features 0.3
├☑ mne-connectivity 0.5.0
├☑ mne-icalabel 0.4
└☑ mne-bids-pipeline 1.4.0

```

Then again running it after restarting MNE, again I can only plot on the pane, cannot interact:

```python
mne.sys_info()
Platform macOS-14.0-arm64-i386-64bit
Python 3.11.5 | packaged by conda-forge | (main, Aug 27 2023, 03:33:12) [Clang 15.0.7]
Executable /Applications/MNE-Python/1.5.1_0/.mne-python/bin/python
CPU i386 (10 cores)
Memory 16.0 GB

Core
├☑ mne 1.5.1
├☑ numpy 1.24.4 (OpenBLAS 0.3.24 with 10 threads)
├☑ scipy 1.11.2
├☑ matplotlib 3.7.2 (backend=module://matplotlib_inline.backend_inline)
├☑ pooch 1.7.0
└☑ jinja2 3.1.2

Numerical (optional)
├☑ sklearn 1.3.0
├☑ numba 0.57.1
├☑ nibabel 5.0.1
├☑ nilearn 0.10.1
├☑ dipy 1.7.0
├☑ openmeeg 2.5.6
├☑ pandas 2.1.0
└☐ unavailable cupy

Visualization (optional)
├☑ pyvista 0.41.1 (OpenGL 4.1 Metal - 86 via Apple M1 Pro)
├☑ pyvistaqt 0.0.0
├☑ vtk 9.2.6
├☑ qtpy 2.4.0 (PyQt5=5.15.8)
├☑ ipympl 0.9.3
├☑ pyqtgraph 0.13.3
├☑ mne-qt-browser 0.5.2
├☑ ipywidgets 8.1.0
├☑ trame_client 2.11.2
├☑ trame_server 2.11.7
├☑ trame_vtk 2.5.8
└☑ trame_vuetify 2.3.1

Ecosystem (optional)
├☑ mne-bids 0.13
├☑ mne-nirs 0.5.0
├☑ mne-features 0.3
├☑ mne-connectivity 0.5.0
├☑ mne-icalabel 0.4
└☑ mne-bids-pipeline 1.4.0

heartbeat_evoked_v1.plot()
Traceback (most recent call last):

  File /Applications/MNE-Python/1.5.1_0/.mne-python/lib/python3.11/site-packages/IPython/core/formatters.py:340 in __call__
    return printer(obj)

  File /Applications/MNE-Python/1.5.1_0/.mne-python/lib/python3.11/site-packages/IPython/core/pylabtools.py:152 in print_figure
    fig.canvas.print_figure(bytes_io, **kw)

  File /Applications/MNE-Python/1.5.1_0/.mne-python/lib/python3.11/site-packages/matplotlib/backend_bases.py:2353 in print_figure
    restore_bbox = _tight_bbox.adjust_bbox(

  File /Applications/MNE-Python/1.5.1_0/.mne-python/lib/python3.11/site-packages/matplotlib/_tight_bbox.py:28 in adjust_bbox
    ax.apply_aspect(locator(ax, None))

  File /Applications/MNE-Python/1.5.1_0/.mne-python/lib/python3.11/site-packages/mpl_toolkits/axes_grid1/inset_locator.py:73 in __call__
    bbox = self.get_window_extent(renderer)

  File /Applications/MNE-Python/1.5.1_0/.mne-python/lib/python3.11/site-packages/matplotlib/offsetbox.py:399 in get_window_extent
    renderer = self.figure._get_renderer()

AttributeError: 'NoneType' object has no attribute '_get_renderer'

Out[11]: <Figure size 460.8x216 with 2 Axes>

```

In general, which backend would you recommend to stick to? I kept switching when one stopped working (plots not appearing at all, or only appearing on the console), but ideally, I would like to stick to one and ensure it keeps working…

I presume I might have used the standalone installer back then, but cannot remember certainly. I am using MNE Spyder.

I feel very stuck at this moment since all my attempts to fix it reached a dead end, thankful to hear your tips!

Best,  
Deniz

---

<div class="post-metadata">

**Author:** ![mscheltienne](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/mscheltienne/32/827_2.png) [@mscheltienne](https://mne.discourse.group/u/mscheltienne)\
**Post date:** [May 3, 2024, 9:22am UTC](https://mne.discourse.group/t/plotting-issues-mne-1-5-1-matplotlib-backend-choice/8741/2 "2024-05-03T09:22:43Z")

</div>

Hello,

It seems you used the installer since the executable is in the path `/Applications/MNE-Python`.  
I’m not sure how you ended in this unclean state, but the simplest is to wipe the installation and get a fresh one. So:

- Please delete `/Applications/MNE-Python`
- Get the latest 1.7 installers for your platform (macOS intel!): [MNE-Python installers — MNE 1.7.0 documentation](https://mne.tools/stable/install/installers.html#installers)
- Run the installation process and start fresh

Mathieu

---

<div class="post-metadata">

**Author:** ![deniz\_yilmaz](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/deniz_yilmaz/32/4497_2.png) [@deniz\_yilmaz](https://mne.discourse.group/u/deniz_yilmaz)\
**Post date:** [May 3, 2024, 9:52am UTC](https://mne.discourse.group/t/plotting-issues-mne-1-5-1-matplotlib-backend-choice/8741/3 "2024-05-03T09:52:35Z")

</div>

> [@mscheltienne](#):
>
> Mathieu

Hi Mathieu,

Thanks for the recommendation. I worry that the error with Anaconda persists and I cannot install anything for some reason (see the error regarding the libmamba).

Any ideas on how to fix the matplotlib backend issue and ensure I can always plot a pop-up figure interactively when I reinstall? Which backend should I prefer for this purpose?

Best  
Deniz

---

<div class="post-metadata">

**Author:** ![mscheltienne](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/mscheltienne/32/827_2.png) [@mscheltienne](https://mne.discourse.group/u/mscheltienne)\
**Post date:** [May 3, 2024, 11:20am UTC](https://mne.discourse.group/t/plotting-issues-mne-1-5-1-matplotlib-backend-choice/8741/4 "2024-05-03T11:20:36Z")

</div>

I think you have a broken/unclean state which is both from MNE and Anaconda. With the procedure above, at least the MNE environment will start working again (since it it independent from your anaconda install); but indeed I would remove both Anaconda and the MNE-install.

Once installed with the installer, you should have in `/Applications/MNE-Python` a terminal with the label MNE, which is the terminal from which you can install additional package in the environment if you need.

* * *

For plotting with matplotlib, I prefer the QtAgg interactive backend. But anyway, it should automatically pick an interactive backend, except if you are in a jupyter notebook in which case you’ll need to add the magic command `%matplotlib qt` in one of the first cells to get interactive pop-up plots in `matplotlib`.

Mathieu

---

<div class="post-metadata">

**Author:** ![deniz\_yilmaz](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/deniz_yilmaz/32/4497_2.png) [@deniz\_yilmaz](https://mne.discourse.group/u/deniz_yilmaz)\
**Post date:** [May 3, 2024, 11:29am UTC](https://mne.discourse.group/t/plotting-issues-mne-1-5-1-matplotlib-backend-choice/8741/5 "2024-05-03T11:29:48Z")

</div>

> [@mscheltienne](#):
>
> Mathieu

Thanks, Mathieu! I will try that out!  
Last question: Do you think creating separate venvs in the MNE-env may circumvent such a complication in the future?

---

<div class="post-metadata">

**Author:** ![mscheltienne](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/mscheltienne/32/827_2.png) [@mscheltienne](https://mne.discourse.group/u/mscheltienne)\
**Post date:** [May 3, 2024, 1:44pm UTC](https://mne.discourse.group/t/plotting-issues-mne-1-5-1-matplotlib-backend-choice/8741/6 "2024-05-03T13:44:04Z")

</div>

Separate virtual environment is the correct way to go, but only if you are comfortable enough with python, venvs, … the installer simplify this process by creating a separated virtual environment with a large number of useful package, and relevant shortcuts.

If you start mixing installer, with conda environment, with pip, you get a mess 😉

Mathieu

---

<div class="post-metadata">

**Author:** ![deniz\_yilmaz](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/deniz_yilmaz/32/4497_2.png) [@deniz\_yilmaz](https://mne.discourse.group/u/deniz_yilmaz)\
**Post date:** [May 13, 2024, 10:50am UTC](https://mne.discourse.group/t/plotting-issues-mne-1-5-1-matplotlib-backend-choice/8741/7 "2024-05-13T10:50:31Z")

</div>

Great!

I hope I am not missing an obvious answer but:  
What are the general guidelines on installing additional packages, which are not included in the installer, if not conda or pip?

Best  
Deniz

---

<div class="post-metadata">

**Author:** ![mscheltienne](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/mscheltienne/32/827_2.png) [@mscheltienne](https://mne.discourse.group/u/mscheltienne)\
**Post date:** [May 13, 2024, 11:10am UTC](https://mne.discourse.group/t/plotting-issues-mne-1-5-1-matplotlib-backend-choice/8741/8 "2024-05-13T11:10:17Z")

</div>

If you used the installer to create the environment, you should have in the created shortcut a `Terminal (MNE)` (or something similar) program which opens a terminal with the environment activated. The installer creates a `conda` environment, thus use `conda` in priority to install additional packages in this environment.

If like me you prefer virtual environment and `pip`, well `conda` is never part of it 😉

Mathieu
