我在另一个脚本中有一个函数可以绘制一个图形,所以这个图形已经被预先绘制好了,我只想把它放到PyQt5接口上的一个小部件中。我已经导入了它,当它运行时会打开两个窗口,一个是图形,一个是用户界面。有什么想法吗?在
代码如下:def minionRatioGraph(recentMinionRatioAvg):
x = recentMinionRatioAvg
a = x*10
b = 100-a
sizes = [a, b]
colors = ['#0047ab', 'lightcoral']
plt.pie(sizes, colors=colors)
#determine score colour as scolour
if x < 5:
scolour = "#ff6961" #red
elif 5 <= x < 5.5:
scolour = "#ffb347" #orange
elif 5.5 <= x < 6.5:
scolour = "#77dd77" #light green
elif 6.5 <= x:
scolour = "#03c03c" # dark green
#draw a circle at the center of pie to make it look like a donut
centre_circle = plt.Circle((0,0),0.75, fc=scolour,linewidth=1.25)
fig = plt.gcf()
fig.gca().add_artist(centre_circle)
# Set aspect ratio to be equal so that pie is drawn as a circle.
plt.axis('equal')
plt.show()
这是一个脚本。在我的GUI脚本中,我导入了以下内容:
^{pr2}$
在我的窗口类开始时,在setup函数之前,我有一个函数:def minionGraphSetup(self, recentMinionRatioAvg):
minionRatioGraph(recentMinionRatioAvg)