比較的大きなアプリケーションを設計しましたが、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()