Yuxiang Wang
Yuxiang Wang

Reputation: 8423

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!

Upvotes: 4

Views: 1865

Answers (3)

SAAD
SAAD

Reputation: 789

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

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

Upvotes: 0

tacaswell
tacaswell

Reputation: 87376

In your rcparam file add the line

backend.qt4 : PySide        # PyQt4 | PySide

Upvotes: 4

Svend Feldt
Svend Feldt

Reputation: 778

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

Upvotes: 1

Related Questions