Python Matplotlib小部件中的多个绘图

Python Matplotlib小部件中的多个绘图,python,graph,matplotlib,pyqt,qt-designer,Python,Graph,Matplotlib,Pyqt,Qt Designer,我设计了一个相对较大的应用程序,但在实现Matplotlibwidget图时遇到了一个问题。这是我处理图形的代码片段 以下代码仅绘制x2和y2的最新绘图 注意:这里self.GraphWidget是使用QtDesigner实现的MatplotlibWidget对象 def Toggled(self,CD): self.GraphWidget.axes.plot(self.x1,self.y1,label='plot1') self.GraphWidget.axes.plot(s

我设计了一个相对较大的应用程序,但在实现Matplotlibwidget图时遇到了一个问题。这是我处理图形的代码片段

以下代码仅绘制x2和y2的最新绘图

注意:这里self.GraphWidget是使用QtDesigner实现的MatplotlibWidget对象

def Toggled(self,CD):

    self.GraphWidget.axes.plot(self.x1,self.y1,label='plot1')
    self.GraphWidget.axes.plot(self.x2,self.y2,label='plot2')        

    self.GraphWidget.axes.set_xscale('log')

    self.GraphWidget.legend()
    self.GraphWidget.draw()
下面的代码(见下文)在图形上绘制了两条曲线,但我更愿意使用上述方法,以便为每条曲线提供单独的标签等:

def Toggled(self,CD):

    self.GraphWidget.axes.plot(self.x1,self.y1,self.x2,self.y2)


    self.GraphWidget.axes.set_xscale('log')

    self.GraphWidget.legend()
    self.GraphWidget.draw()

尝试显式设置保持:

self.GraphWidget.axes.hold(True)
self.GraphWidget.axes.plot(self.x1,self.y1,label='plot1')
self.GraphWidget.axes.plot(self.x2,self.y2,label='plot2')  

确保代码中没有
hold=False
someplace@tcaswell不,我没有。我发现处理Qt设计器创建的matplotlib小部件非常困难。我不想通过硬编码实现Matplotlib小部件来修改太多UI代码,因为它是一个相当庞大的应用程序,Qt designer已经帮助我相当顺利地实现了其他所有功能。我正在考虑切换到qwt绘图(有什么建议吗)?如果上述情况可以解决,我当然愿意坚持下去。