应用场景:gui里要用matplotlib画图并显示
首先,你的图如果要显示在一个widget里,那么要在py文件里把它改为
self.figure, self.ax = plt.subplots(1, 1)
self.widget_spectrum = FigureCanvas(self.figure)
然后你就可以在ax上画图了
self.ax.plot(x, y)
然后你在widget上画
self.widget_spectrum .draw()
然后就会在ui上显示你画的图了。
其余的可以参考其他帖子,搜索pyqt5嵌入matplotlib,或者matplotlib嵌入pyqt5