我只想在我的程序上绘制图表。我需要使用axes.clear()
多次绘制新图表。
from PyQt4 import QtGui
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.figure import Figure
class MplCanvas(FigureCanvas):
def __init__(self):
self.fig = Figure()
self.axes = self.fig.add_subplot(111)
# do something...
FigureCanvas.__init__(self, self.fig)
FigureCanvas.setSizePolicy(self, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
FigureCanvas.updateGeometry(self)
# do something...
def refresh(self):
# FIXME: This method is very, very slow!!!
self.axes.clear()
# do something...
但它很慢,它会挂起我的程序大约 0.3 秒。正常吗?