Matplotlib + PyQt无法在OX

时间:2015-08-20 01:42:54

标签: python qt canvas matplotlib pyqt4

我正在开发一个使用PyQt4和Matplotlib的程序(顺便说一句)。然而,我们的一个用户无法运行它,我能够在以下脚本中找出问题(在我的Debian中有效)

#!/usr/bin/env python
import sys
import matplotlib

matplotlib.use('Qt4Agg')
matplotlib.rcParams['backend.qt4']='PyQt4'

from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.figure import Figure

from PyQt4 import QtCore, QtGui

app = QtGui.QApplication(sys.argv)

# generate the plot
fig = Figure(figsize=(600,600), dpi=72, facecolor=(1,1,1), edgecolor=(0,0,0))
ax = fig.add_subplot(111)
ax.plot([0,1])
# generate the canvas to display the plot
canvas = FigureCanvas(fig)

win = QtGui.QMainWindow()
# add the plot canvas to a window
win.setCentralWidget(canvas)

win.show()

sys.exit(app.exec_())

这给了他以下错误:

Traceback (most recent call last): File "/tmp/testmp", line 24, in <module> win.setCentralWidget(canvas) TypeError: QMainWindow.setCentralWidget(QWidget): argument 1 has unexpected type ‘FigureCanvasQTAgg'

他的配置

OX 10.10.5 with conda 3.16.0

Python 2.7.10 | Anaconda 2.3.0(x86_64)

matplotlib 1.4.3

Qt 4.8.6

PyQt 4.11.3

我看起来像互联网,但没有找到任何帮助。我想知道是否有人有任何想法,为什么会发生这种情况,如果我应该向前推进并在Matplotlib的github中打开一个问题。

0 个答案:

没有答案