当我试图运行下面的代码时,这个代码是在一个名为绘图.py
import sys
# Python Qt4 bindings for GUI objects
from PyQt4 import QtGui
# Numpy functions for image creation
import numpy as np
# Matplotlib Figure object
from matplotlib.figure import Figure
# import the Qt4Agg FigureCanvas object, that binds Figure to
# Qt4Agg backend. It also inherits from QWidget
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
class Qt4MplCanvas(FigureCanvas):
"""Class to represent the FigureCanvas widget"""
def __init__(self):
# Standard Matplotlib code to generate the plot
self.fig = Figure()
self.axes = self.fig.add_subplot(111)
self.x = np.arange(0.0, 3.0, 0.01)
self.y = np.cos(2*np.pi*self.x)
self.axes.plot(self.x, self.y)
# initialize the canvas where the Figure renders into
FigureCanvas.__init__(self, self.fig)
# Create the GUI application
qApp = QtGui.QApplication(sys.argv)
# Create the Matplotlib widget
mpl = Qt4MplCanvas()
# show the widget
mpl.show()
# start the Qt main loop execution, exiting from this script
# with the same return code of Qt application
sys.exit(qApp.exec_())
我得到了完整的错误信息
^{pr2}$我是新编程的,我做了一些关于这个错误的研究,没有收获。在
目前没有回答
相关问题 更多 >
编程相关推荐