python - Can't add legend in figure -
i want add legend figure, doesn't show. in code below "forecast_canvas" instance of class canvas created in qt designer. ax = self.forecast_canvas.figure.add_subplot(111) ax.plot(self.new,'--',label='observed') ax.plot(data,color='green',label='forecast') self.forecast_canvas.draw() here's code of canvas : from matplotlib.backends.backend_qt4agg import figurecanvasqtagg figurecanvas import matplotlib.pyplot plt pyqt4 import qtgui class canvas(figurecanvas): def __init__(self, parent=none): self.figure = plt.figure() #plt.tight_layout(pad=4) figurecanvas.__init__(self, self.figure) self.setparent(parent) figurecanvas.setsizepolicy(self, qtgui.qsizepolicy.expanding, qtgui.qsizepolicy.expanding) figurecanvas.updategeometry(self) #plt.legend() i tried adding plt.legend() ...