I have designed a relatively large application but I am facing a problem in implementing the Matplotlibwidget graphs. This is the snippet of code where I am handling the graph.
The following code only plots the latest plot that of x2 and y2.
Note: here self.GraphWidget is a MatplotlibWidget object implemented using QtDesigner
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()
The following code (see below) plots both curves on the graph but I'd rather use the above method so that I can give individual labels etc to each curve:
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()
Try explicitly setting hold:
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')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With