简体   繁体   中英

PySide instead of PyQt4 as the prerequisite for matplotlib Qt4Agg backend

I have a quick question with regard to the prerequisite of using Qt4Agg backend with matplotlib. In the documentation , it said Qt4Agg requires PyQt4. However, since matplotlib can now work perfectly with PySide instead of PyQt4, can I install PySide only? Do I still need to install PyQt4 to let matplotlib work with Pyside?

I am asking this question because in the example of using matplotlib with PySide, the backend has to be switched to Qt4Agg and requires PyQt4 according to the documentation.

Thanks!

在你的rcparam文件中添加该行

backend.qt4 : PySide        # PyQt4 | PySide

You only have to install Pyside. and then do something like this

os.environ['QT_API'] = 'pyside' 
from matplotlib import use
use('Qt4Agg') 
import pylab as plt

In addition to the accepted answer, if you don't want to modify the rcParam file:

from matplotlib import rc
rc('backend', qt4="PySide")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM