__init__参数数量不正确

时间:2016-12-26 23:53:16

标签: python matplotlib pyqt

我很确定我传递了正确数量的参数,但由于某种原因,它表明我缺少一个位置参数('数字'),但我正在传递图;因此我的困惑。这是我的代码:

from PyQt5.QtWidgets import QApplication, QDialog, QPushButton,QVBoxLayout
import sys

from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT as NavigationToolbar
import matplotlib.pyplot as plt

class Window(QDialog):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.figure = plt.figure()
        self.ax = self.figure.add_subplot(1,1,1)
        self.canvas = FigureCanvas(self.figure)

最后一行出错了。我做错了什么?

File "C:\Users\...\matplotlib\backends\backend_qt4agg.py", line 76, in __init__
FigureCanvasQT.__init__(self, figure)
File "C:\Users\...\matplotlib\backends\backend_qt4.py", line 71, in __init__
QtWidgets.QWidget.__init__(self)
TypeError: __init__() missing 1 required positional argument: 'figure'

0 个答案:

没有答案