简体   繁体   English

PySide代替PyQt4作为matplotlib Qt4Agg后端的先决条件

[英]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. 关于使用Qt4Agg后端和matplotlib的先决条件,我有一个简单的问题。 In the documentation , it said Qt4Agg requires PyQt4. 文档中 ,它说Qt4Agg需要PyQt4。 However, since matplotlib can now work perfectly with PySide instead of PyQt4, can I install PySide only? 但是,由于matplotlib现在可以与PySide而不是PyQt4完美配合,我可以只安装PySide吗? Do I still need to install PyQt4 to let matplotlib work with Pyside? 我还需要安装PyQt4让matplotlib与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. 我问这个问题,因为在使用matplotlib和PySide的例子中,后端必须切换到Qt4Agg并根据文档需要PyQt4。

Thanks! 谢谢!

在你的rcparam文件中添加该行

backend.qt4 : PySide        # PyQt4 | PySide

You only have to install Pyside. 你只需要安装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: 除了接受的答案,如果您不想修改rcParam文件:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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