-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Description
Currently, when users select qt
with %gui qt
or %matplotlib qt
, IPython forces matplotlib to switch to Qt5Agg
first, before matplotlib's qt_compat.py
kicks in (which, if run on its own, can actually pick up the right Qt bindings installed).
ipython/IPython/core/pylabtools.py
Line 26 in 396593e
"qt": "Qt5Agg", |
ipython/IPython/core/pylabtools.py
Lines 301 to 322 in 396593e
def find_gui_and_backend(gui=None, gui_select=None): | |
"""Given a gui string return the gui and mpl backend. | |
Parameters | |
---------- | |
gui : str | |
Can be one of ('tk','gtk','wx','qt','qt4','inline','agg'). | |
gui_select : str | |
Can be one of ('tk','gtk','wx','qt','qt4','inline'). | |
This is any gui already selected by the shell. | |
Returns | |
------- | |
A tuple of (gui, backend) where backend is one of ('TkAgg','GTKAgg', | |
'WXAgg','Qt4Agg','module://matplotlib_inline.backend_inline','agg'). | |
""" | |
import matplotlib | |
if gui and gui != 'auto': | |
# select backend based on requested gui | |
backend = backends[gui] |
This isn't documented and has caused me a lot of confusion and trouble (and will cause further trouble in the future as usage of Qt6 increases over Qt5):
- https://ipython.readthedocs.io/en/stable/interactive/magics.html#magic-matplotlib
- https://ipython.readthedocs.io/en/stable/interactive/magics.html#magic-gui
I found out about this after spending months trying to work out why %matplotlib qt
doesn't work when I have Qt6 bindings installed: matplotlib/matplotlib#25673 (comment)
I suggest we either explicitly document this in the IPython line magic docs, or we change this default behavior.
Relevant but not duplicate: