【发布时间】:2020-03-12 09:20:27
【问题描述】:
我正在制作一个使用 python pyqt5 和 matplotlib 显示图形的应用程序。 这是图表的问题,我不知道为什么会这样。
您可以看到我上传的 2 个图形图像。 第二个是我想展示的。 但是在显示饼图之后(我的应用程序中使用了很多类型的图,但只有在饼图发生此问题之后),它就像第一张图片一样工作。
所以,我在画饼图之后写了代码
self.MplWidget.canvas.axes.clear() 像这样。
但它根本没有改变。
如果我重新启动我的应用程序,它运行良好。
如何在显示饼图后显示我的图表,如 image2?
这是我显示条形图的代码
self.MplWidget.canvas.axes.bar(ind, graph1, width, label='price1' )
self.MplWidget.canvas.axes.bar(ind, graph2, width, bottom=graph1, yerr=Std, label='price2')
self.MplWidget.canvas.axes.title.set_text('graph1')
self.MplWidget.canvas.axes.set_xticks(ind)
self.MplWidget.canvas.axes.set_xticklabels(temp['date'], rotation=90 )
self.MplWidget.canvas.axes.legend(loc='best')
self.MplWidget.canvas.draw()
这是我显示饼图的代码
self.MplWidget.canvas.axes.title.set_text('pie graph')
self.MplWidget.canvas.axes.pie(sizes, labels=labels, autopct='%1.1f%%',shadow=True, startangle=90)
self.MplWidget.canvas.axes.axis('equal')
self.MplWidget.canvas.draw()
self.MplWidget.canvas.axes.clear()
【问题讨论】:
标签: matplotlib pyqt5 python-3.7