如何使用python创建饼图?

如何使用python创建饼图?,python,python-2.7,Python,Python 2.7,我正在使用python执行一个自动化测试套件,我希望控制台结果以饼图的形式显示,我希望通过和失败都出现在图表中,绿色的通过和红色的失败,有没有任何方法可以从控制台结果创建饼图?: 用谷歌查询在5秒内找到!!在导入六个导入时,我在导入“来自pylab导入*”文件“C:\Python27\lib\site packages\pylab.py”的第1行,从matplotlib.pylab导入*文件“C:\Python27\lib\site packages\matplotlib init\uu.py”

我正在使用python执行一个自动化测试套件,我希望控制台结果以饼图的形式显示,我希望通过和失败都出现在图表中,绿色的通过和红色的失败,有没有任何方法可以从控制台结果创建饼图?


用谷歌查询在5秒内找到!!在导入六个导入时,我在导入“来自pylab导入*”文件“C:\Python27\lib\site packages\pylab.py”的第1行,从matplotlib.pylab导入*文件“C:\Python27\lib\site packages\matplotlib init\uu.py”的第105行,导入时遇到此错误。错误:没有名为六的模块
from pylab import *

# make a square figure and axes
figure(1, figsize=(6,6))
ax = axes([0.1, 0.1, 0.8, 0.8])

# The slices will be ordered and plotted counter-clockwise.
labels = 'Pass', 'Fail'
fracs = [75, 25]
explode=(0, 0.05, 0, 0)

pie(fracs, explode=explode, labels=labels,
                autopct='%1.1f%%', shadow=True, startangle=90)

title('Pass/Fail', bbox={'facecolor':'0.8', 'pad':5})

show()
import matplotlib.pyplot as plt

#change these 2 variables to suit your needs
nPass = 5857 
nFail = 1362

plt.rcParams.update({'font.size': 22}) #adjust font size; not really needed

plt.pie([nPass, nFail],
        colors=["green","red"],
        labels=["Pass", "Fail"],
        autopct='%1.1f%%', 
        startangle=90)

plt.axis('equal') #ensure pie is round
plt.show()